Gathering detailed insights and metrics for expression-eval
Gathering detailed insights and metrics for expression-eval
Gathering detailed insights and metrics for expression-eval
Gathering detailed insights and metrics for expression-eval
JavaScript expression parsing and evaluation.
npm install expression-eval
Typescript
Module System
Node Version
NPM Version
99.5
Supply Chain
93.5
Quality
75.7
Maintenance
100
Vulnerability
100
License
TypeScript (59%)
JavaScript (41%)
Total Downloads
39,194,719
Last Day
41,078
Last Week
228,789
Last Month
964,264
Last Year
10,634,396
MIT License
198 Stars
123 Commits
48 Forks
7 Watchers
1 Branches
14 Contributors
Updated on Oct 03, 2024
Minified
Minified + Gzipped
Latest Version
5.0.1
Package Id
expression-eval@5.0.1
Unpacked Size
76.26 kB
Size
10.92 kB
File Count
12
NPM Version
9.7.1
Node Version
18.12.1
Published on
Jun 19, 2023
Cumulative downloads
Total Downloads
Last Day
66.7%
41,078
Compared to previous day
Last Week
-0.7%
228,789
Compared to previous week
Last Month
3%
964,264
Compared to previous month
Last Year
10.1%
10,634,396
Compared to previous year
1
JavaScript expression parsing and evaluation.
⚠️ UNMAINTAINED: The
expression-eval
npm package is no longer maintained. The package was originally published as part of a now-completed personal project, and I do not have incentives to continue maintenance. Please feel free to use the code, but be aware that support and updates will not be available.
⚠️ SECURITY NOTICE: 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:
1// ES6 2import { parse, eval } from 'expression-eval'; 3// CommonJS 4const { parse, eval } = require('expression-eval'); 5// UMD / standalone script 6const { parse, eval } = window.expressionEval;
1import { parse } from 'expression-eval'; 2const ast = parse('1 + foo');
The result of the parse is an AST (abstract syntax tree), like:
1{ 2 "type": "BinaryExpression", 3 "operator": "+", 4 "left": { 5 "type": "Literal", 6 "value": 1, 7 "raw": "1" 8 }, 9 "right": { 10 "type": "Identifier", 11 "name": "foo" 12 } 13}
1import { parse, eval } from 'expression-eval'; 2const ast = parse('a + b / c'); // abstract syntax tree (AST) 3const value = eval(ast, {a: 2, b: 2, c: 5}); // 2.4
Alternatively, use evalAsync
for asynchronous evaluation.
1import { compile } from 'expression-eval'; 2const fn = compile('foo.bar + 10'); 3fn({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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/17 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More