1.1.0 • Published 10 years ago
formula-compiler v1.1.0
Formula Compiler
Compile spreadsheet formulas to JavaScript functions.
Install
npm install formula-compilerUsage
First you must require the compiler.
var compiler = require('formula-compiler');Then you need a data object and a context that supports
a get function.
var data = { SuccessText: "Works!" };
var context = { get: function(key) { return data[key]; } };Use the compiler to generate a function.
var myFunction = compiler.compile('IF(TRUE, SuccessText, "Broken")');Run the function passing back in the requirements.
var result = myFunction(context, myFunction.requires)Properties
The function comes with metadata.
The identifier:
myFunction.idThe abstract syntax tree:
myFunction.astThe list of required libraries:
myFunction.requiresThe list of precedents:
myFunction.precedents