Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@emmetio/math-expression
Advanced tools
Fast and small (less than 2KB minified and gzipped) zero-dependency math expression parser and evaluator.
import evaluate from '@emmetio/math-expression';
console.log(evaluate('2 * (-3 + 5)')); // 4
In JavaScript, you can use built-in eval()
function to evaluate expressions:
console.log(eval('2 * (-3 + 5)')); // 4
But in most modern JavaScript environments eval()
function is considered harmful since it can evaluate any arbitrary JS code. And in some cases (like in Atom editor) it’s disabled by default due to security reasons.
With @emmetio/math-expression
module you can safely parse & evaluate basic math expressions in any JS environment.
This module is used by Emmet project to evaluate math expression in-place in code source. A default user workflow is to enter math expression somewhere in source code and run action to evaluate it. You can use extract
function to extract math expression from given source code, starting at specified position:
import evaluate, { extract } from '@emmetio/math-expression';
const code = 'Here goes math: 2 + 3 foo bar';
const [start, end] = extract(code, 21); // 16, 21
const expr = code.substring(start, end); // 2 + 3
console.log(evaluate(expr)); // 5
FAQs
Parse and evaluate simple math expressions
The npm package @emmetio/math-expression receives a total of 7,977 weekly downloads. As such, @emmetio/math-expression popularity was classified as popular.
We found that @emmetio/math-expression demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.