Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathematician

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathematician - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

2

package.json
{
"name": "mathematician",
"version": "0.1.0",
"version": "0.2.0",
"description": "Arithmetical expressions parser for Elm and JavaScript",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

# mathematician
Arithmetical expressions parser for JavaScript. 数学者!
> Available on NPM: https://www.npmjs.com/package/mathematician
## Examples
It splits expressions into atomic symbols for easy programming handling.
```js
parseExpression('-3,14 0.57 +');
// returns them:
[
{ type: SYMBOL_TYPE.NUMBER, value: -3.14 },
{ type: SYMBOL_TYPE.NUMBER, value: 0.57 },
{ type: SYMBOL_TYPE.SUM, value: null },
]
parseExpression('42c');
// throws error indexing failing token:
Error('2')
```
And may also safely evaluate whole expressions following
[postfix notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation):
```js
evalPostfix('1 1 + 2 + 3 +');
// returns the result:
7
evalPostfix('42 0 /');
// throws error messaging arithmetical inconsistency:
Error('Division by zero')
```
import evalPostfix from './evals';
import { parseExpression } from './parser';
import * as syntax from './syntax';
export default {
evalPostfix,
parseExpression,
...syntax,
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc