1.0.1 • Published 6 years ago

fxparser v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

F(x) parser

Library provides a Parser class that evaluates excel and mathematical formulas.

  1. Installation
  2. Implementation
    1. Html
    2. js
  3. Features
  4. API

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