0.0.6 • Published 7 years ago

jaune-util v0.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Build Status

jaune-util package

Set of utilities such as reflection, validators and time among others

Install

npm install jaune-util

Run tests

npm test

Reflection

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.

Get a reference by name

You can get a reference by name easily:

var evaluateName = require('jaune-util').Reflection.evaluateName

evaluateName('foo.bar', { foo : { bar : 'my bar' } }); // 'my bar'

Get a reference by requiring a path

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

Get a reference by requiring a module

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

Get the result by calling a function

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

Get the result of creating an instance

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}
0.0.6

7 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago