node lambda compiler with cache.
$ npm install epiclambda
Example basic.js:
var lambda = require('epiclambda');
var func = lambda('e => e > 1');
var data = [0, 1, 2, 3];
console.log(data.filter(func));
You can access the anonymous function using $(Array)
Example anonymous.js:
var func = lambda('e => $[0](e) && e > 1', function(e){ return e < 3 });
var data = [0, 1, 2, 3];
console.log(data.filter(func));
Example named.js:
var func = lambda('e => action(e) && e > 1', function action(e){ return e < 3 });
var data = [0, 1, 2, 3];
console.log(data.filter(func));
or like this:
var func = lambda('e => action(e) && e > 1', {action: function (e){ return e < 3 }});
var data = [0, 1, 2, 3];
console.log(data.filter(func));
Example lambda.js:
var func = lambda('e => $[0](e) && e > 1', 'e => e <3');
var data = [0, 1, 2, 3];
console.log(data.filter(func));
Example paramObj.js:
var func = lambda({exp: 'e => action(e) && e > 1', action: function(e){ return e < 3 }});
var data = [0, 1, 2, 3];
console.log(data.filter(func));
You can use any format you want. have fun. :)
Example mix.js:
var func = lambda('e => $[0](e) && $[1](e) && $[2](e) && action1(e) && action2(e) && e > 1', ['e => e < 3', function(e){ return e < 3 }], 'e => e < 3', {action1: 'e => e < 3', action2: function(e){ return e < 3} }, function(e) { return e < 3;});
var data = [0, 1, 2, 3];
console.log(data.filter(func));