Socket
Socket
Sign inDemoInstall

expression-compiler

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    expression-compiler

expression ==========


Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

expression

Build Status

fun with math expressions

Install

$ npm install expression-compiler

Usage

> var compile = require('expression');
undefined
> var var exprFn = compile('c*sin(2*t)+1');
undefined
> exprFn({c: 0.5, sin: Math.sin, t: Math.PI});
0.9999999999999999

Parsing

New AST node design:

{
  id: 0,
  type: 'ASTNode',
  node: 'expr',
  template: '#',
  children: [],
  options: {}
}
  • id must be unique
  • type must be a valid node type
  • options contains different properties depending on the node type

AST Node Types

expr

options:

{}
func

options:

{
  key: 'funcName'
}

Infix functions should be normal function nodes. Here are some examples for + with 2 or 3 operands:

{
  id: 0,
  type: 'ASTNode',
  node: 'func',
  template: '# + # + #',
  children: [someNode, anotherNode, andAnother],
  options: {
    key: 'sum'
  }
}

Normal functions can take multiple arguments

{
  id: 0,
  type: 'ASTNode',
  node: 'func',
  template: 'min(#, #)',
  children: [someNode, anotherNode],
  options: {
    key: 'min'
  }
}
name

options:

{
  key: 'varName'
}

literal

options:

{
  value: 1
}

FAQs

Last updated on 18 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc