x2-formula
v1.0.5
Published
formula
Downloads
3
Readme
x2-formula
Installation
npm install x2-formula
const x2formula= require('x2-formula')
API
formula processing utils
x2formula.formulaValue(formula = '', data = {})
formula:string, // formula like '{value1} / {value2}'
data: object // {value1:1, value2: 1}
x2formula.formulaValues({formula='', data=[], dataKey='formulaName', fields=['value1', 'value2']})
formula:string, // formula like '{name1} + {name2}'
data: object // [{value1:1, value2: 1, formulaName: 'name1'},{value1:1, value2: 1, formulaName: 'name2'}]
fields:arr, // need to calc field
dataKey: string // data's mapping formula's field name
x2formula.computed({formulas = [], data = [], dataKey='formulaName', fields = ['value1', 'value2']})
formula:array, // formula like {formulaName:'name1', formula: '{{name11}} + {{name12}}'}, {formulaName: 'name0', formula: '{{name1}} + {{name2}} - {{name3}}'}]
data: object // [{value1:1, value2: 1, formulaName: 'name1'},{value1:1, value2: 1, formulaName: 'name2'}]
fields:arr, // need to calc field
dataKey: string // data's mapping formula's field name