@collinbrewer/expression
v0.4.1
Published
A utility for node and browser that evaluates objects against an expression.
Downloads
15
Readme
Expression
A utility for node and browser that evaluates objects against an expression.
Install
npm install @collinbrewer/expression -S
Usage
var Expression=require("expression");
Constants:
Expression.parse("'Value'").getValueWithObject(); // -> 'Value'
Expression.parse("4").getValueWithObject(); // -> 4
Functions:
var doc={firstName:"Chris", lastName:"Ericson"}
Expression.parse("concat('firstName', ' ', 'lastName')").getValueWithObject(doc); // -> "Chris Ericson"
Arithmetic:
Expression.parse("1+2+3").getValueWithObject(); // -> 6
Expression.parse("multiply(2, 6)"); // -> 12