1.0.1 • Published 6 years ago
fxparser v1.0.1
F(x) parser
Library provides a Parser
class that evaluates excel and mathematical formulas.
Installation
$ npm install fxparser --save
Implementation
Html
<script src="/node_modules/fx-parser/dist/fxparser.min.js"></script>
var parser = new fxParser.Parser();
parser.parse('SUM(1, 3, 9)');
// It returns `Object {error: null, result: 13}`
js
var FxParser = require('fxparser').Parser;
var parser = new FxParser();
parser.parse('SUM(1, 3, 9)');
// It returns `Object {error: null, result: 13}`
Features
It supports:
- Any numbers, negative and positive as float or integer;
- Arithmetic operations like
+
,-
,/
,*
,%
,^
; - Logical operations like
AND()
,OR()
,NOT()
,XOR()
; - Comparison operations like
=
,>
,>=
,<
,<=
,<>
; - All JavaScript Math constants like
PI()
,E()
,LN10()
,LN2()
,LOG10E()
,LOG2E()
,SQRT1_2()
,SQRT2()
; - String operations like
&
(concatenation eq.parser.parse('-(2&5)');
will return-25
); - Relative and absolute cell coordinates like
A1
,$A1
,A$1
,$A$1
; - Build-in variables like
TRUE
,FALSE
,NULL
- Custom variables;
- Custom functions/formulas;
- Node and Browser environment.
API
$ node runthistest.js