0.0.0-alpha.b8fdd81b0fb9f4653db4281bc0c7c1c391c9f6db • Published 4 years ago

meljs v0.0.0-alpha.b8fdd81b0fb9f4653db4281bc0c7c1c391c9f6db

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Mel is Minimun Expression Language

  • Mel has a simple JavaScript-like syntax.
  • Mel can be run in any language.
  • Mel is strict about the type.

Install

$ npm install meljs

Usage

const {parse,evalExpression} = require("meljs");
const ast = parse("foo < (bar + 3) * 5");
console.log(evalExpression(ast,{foo:15,bar:1})); //true
console.log(evalExpression(ast,{foo:10,bar:-2})); //false

API

parse


convert string to AST

(text:string) => Expression

evalExpression


compute to value(number | string | boolean) from AST and variables

(experssion:Expression,variables:Variables) => number | string | boolean

CLI demo

npx mel

Syntax

see E2E Test Cases