Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
js-expression-eval
Advanced tools
Javascript based string expression evaluation library.
This library can evaluate a string expression and return the result. It supports basic arithmetic operations like addition, subtraction, multiplication, division and modulus. It also supports variables and functions.
yarn add js-expression-eval
npm install js-expression-eval
import ExpressionParser from 'js-expression-eval';
const parser = new ExpressionParser(expression, variables?);
const result = parser.evaluate();
import ExpressionParser from 'js-expression-eval';
const parser = new ExpressionParser('2 + 3');
const result = parser.evaluate();
console.log(result); // 5
import ExpressionParser from 'js-expression-eval';
const parser = new ExpressionParser('x + y.z', { x: 2, y: { z: 3 } });
const result = parser.evaluate();
console.log(result); // 5
import ExpressionParser from 'js-expression-eval';
const parser = new ExpressionParser('A + B', { A: 2, B: () => 3 });
const result = parser.evaluate();
console.log(result); // 5
import ExpressionParser from 'js-expression-eval';
const parser = new ExpressionParser('A.B + A.C' ,
{
A: (identifier) => {
switch (identifier) {
case 'B':
return 2;
case 'C':
return 3;
}
}
});
const result = parser.evaluate();
console.log(result); // 5
By default the parser has list predefined functions.
If you want to add a new function to the parser, please create a new issue with the function name and the function description. We will add the function to the parser as soon as possible.
FAQs
JS expression evaluation package
The npm package js-expression-eval receives a total of 0 weekly downloads. As such, js-expression-eval popularity was classified as not popular.
We found that js-expression-eval demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.