JSPM

  • Created
  • Published
  • Downloads 908
  • Score
    100M100P100Q102833F
  • License MIT

Formula runtime for JavaScript.

Package Exports

  • formula

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (formula) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

formula

circleci

Formula language for Node.js and Browser, modeled after spreadsheets.

Install

npm install --save formula

Usage

  1. Require the compiler.

    var compiler = require('formula');

Then you need a data object and a context that supports a get function.

var data = { successText: "Works!", errorText: "Broken!" };
var context = { get: function(key) { return data[key]; } };

Use the compiler to generate a function.

var myFunction = compiler.compile('if(true, successText, errorText)');

Run the function passing back in the requirements by calling resolve().

var result = myFunction(context, myFunction.resolve())

Properties

The function includes properties:

The identifier:

myFunction.id

The abstract syntax tree:

myFunction.ast

The list of required functions:

myFunction.requires

The list of precedents:

myFunction.precedents

dist

The scripts in dist are package for the browser with browserify. They use the namespace of formula.