Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
math-expression-evaluator
Advanced tools
The math-expression-evaluator is an npm package that allows for parsing and evaluating mathematical expressions. It can handle various mathematical operations, including basic arithmetic, logical operations, and functions.
Evaluating Mathematical Expressions
This feature allows for the evaluation of a string-based mathematical expression, including support for functions like square root.
var mexp = require('math-expression-evaluator');
var result = mexp.eval('2+3*sqrt(4)');
Support for Variables in Expressions
This feature enables the evaluation of expressions with variables, where the values of the variables can be provided as an object.
var mexp = require('math-expression-evaluator');
var result = mexp.eval('x^2 + y', {x: 3, y: 4});
Custom Functions
This feature allows users to add custom functions to the evaluator, which can then be used in expressions.
var mexp = require('math-expression-evaluator');
mexp.addToken([
{type: 3, token: 'sum', show: 'sum', value: function(a, b) { return a + b; }}
]);
var result = mexp.eval('sum(1,2)');
Logical Operations
This feature supports logical operations within expressions, enabling the evaluation of expressions that include logical comparisons.
var mexp = require('math-expression-evaluator');
var result = mexp.eval('1 < 2 && 3 > 2');
Math.js is an extensive math library for JavaScript and Node.js. It provides a wide range of features including support for units, complex numbers, matrices, and a large number of mathematical functions. Math.js is more feature-rich and can be considered more advanced than math-expression-evaluator.
Algebra.js allows you to define algebraic expressions and equations and perform operations on them. It is more focused on algebraic structures like fractions and equations compared to math-expression-evaluator, which is more about evaluating general mathematical expressions.
Nerdamer is a JavaScript library for symbolic mathematics. It is capable of handling symbolic expressions, calculus, algebra, and solving equations. Nerdamer provides more advanced features for symbolic computation compared to math-expression-evaluator.
A simple but efficient evaluator for Math expression using Javascript
Using npm
npm install math-expression-evaluator
Using bower
bower install math-expression-evaluator
npm test
##Release History
*1.0.0
FAQs
A flexible math expression evaluator
We found that math-expression-evaluator demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.