Bump nanoid from 3.1.23 to 3.3.4 Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.23 to 3.3.4. - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.1.23...3.3.4) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
JavaScript expression parsing and evaluation.
IMPORTANT: As mentioned under Security below, this library does not attempt to provide a secure sandbox for evaluation. Evaluation involving user inputs (expressions or values) may lead to unsafe behavior. If your project requires a secure sandbox, consider alternatives such as vm2.
Powered by jsep.
Install:
npm install --save expression-eval
Import:
// ES6 import { parse, eval } from 'expression-eval'; // CommonJS const { parse, eval } = require('expression-eval'); // UMD / standalone script const { parse, eval } = window.expressionEval;
import { parse } from 'expression-eval'; const ast = parse('1 + foo');
The result of the parse is an AST (abstract syntax tree), like:
{ "type": "BinaryExpression", "operator": "+", "left": { "type": "Literal", "value": 1, "raw": "1" }, "right": { "type": "Identifier", "name": "foo" } }
import { parse, eval } from 'expression-eval'; const ast = parse('a + b / c'); // abstract syntax tree (AST) const value = eval(ast, {a: 2, b: 2, c: 5}); // 2.4
Alternatively, use evalAsync for asynchronous evaluation.
import { compile } from 'expression-eval'; const fn = compile('foo.bar + 10'); fn({foo: {bar: 'baz'}}); // 'baz10'
Alternatively, use compileAsync for asynchronous compilation.
Although this package does avoid the use of eval(), it cannot guarantee that user-provided expressions, or user-provided inputs to evaluation, will not modify the state or behavior of your application. This library does not attempt to provide a secure sandbox for evaluation. Evaluation of arbitrary user inputs (expressions or values) may lead to unsafe behavior. If your project requires a secure sandbox, consider alternatives such as vm2.
MIT License.