Set of utilities such as reflection, validators and time among others
npm install jaune-util
npm test
Reflection gives you the possibility to obtain / call / instantiate members with a string expression. This means you don`t need to know prototypes before hand.
You can get a reference by name easily:
var evaluateName = require('jaune-util').Reflection.evaluateName
evaluateName('foo.bar', { foo : { bar : 'my bar' } }); // 'my bar'
Obtain a reference of a module by requering a it`s path. Imagine you have the following tree:
root |--my_module |--test
var evaluateName = require('jaune-util').Reflection.evaluateName
evaluateName('r[(/my_module)]'); // my_module exports
Obtain a reference of a module that exists inside your node_modules:
var evaluateName = require('jaune-util').Reflection.evaluateName
evaluateName('m[(/assert)]'); // requires assert module
You can call a function with a full path; plus you can specify params:
var evaluateName = require('jaune-util').Reflection.evaluateName
evaluateName('foo.fn.c[(p1, p2)]', {foo: { fn: function(arg1, arg2) { return arg1 + arg2; } }, p1: 2, p2: 10 }) // returns 12
You can an instance with a full path; plus you can specify params:
var evaluateName = require('jaune-util').Reflection.evaluateName
evaluateName('foo.fn.i[(p1, p2)]', {
foo: {
fn: function(arg1, arg2) {
this.arg1 = arg1 + 10;
this.arg2 = arg2 + 10;
}
},
p1: 2, p2: 10 }) // returns {arg1: 12, arg2: 20}