Skip to content

slightboy/lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda

node lambda compiler with cache.

Installation

$ npm install epiclambda

Usage

Example basic.js:

var lambda = require('epiclambda');
var func = lambda('e => e > 1');
var data = [0, 1, 2, 3];

console.log(data.filter(func));

With Anonymous Function

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));

With Named Function

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));

With Other lambda Expression

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));

With Param Object

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));

Mix

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));

Authors

Releases

No releases published

Packages

No packages published