🚀. Socket Launch Week Day 3:Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions.Learn more
Sign In

seljs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seljs

Simple Expression Language for JavaScript

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
5
-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Simple Expression Language for JavaScript

Build Status

Requirements:

  • Nodejs 4+

Install

npm install seljs --save

Features

  • No side effects
  • Fast and simple: small memory footprint
  • No dependencies
  • Simplified property access
  • Expression cache

Language features

  • Arithmetic, relation, equality and boolean opeations
  • Groups
  • Context and property access
  • Literals: Strings and integers
  • String concatenation
  • Keywords: true, false and null

Work in progress

  • Unary: not, minus
  • Functions
  • Global functions
  • Language and operators documentation
  • Floats
  • Array Literals
  • Date literals
  • Datetime literals

Examples

const seljs = require("seljs"),
    assert = require("assert"),
    ctx = {
        int: 123,
        str: "123",
        obj: {
            int: 321,
            str: "321",
            obj: {
                deep: 333
            }
        }
    };

//Number literals
assert.strictEqual(seljs("123"), 123);

//String literals
assert.strictEqual(seljs("'123'"), "123");

//Basic arithmetic
assert.strictEqual(seljs("1 + 3 * 2 / 4 - 1 * 2"), 1 + 3 * 2 / 4 - 1 * 2);

//String concatenation
assert.strictEqual(seljs("'123' + '123'"), "123123");

//Context and property access
assert.strictEqual(seljs("int + obj.int + obj.obj.deep", ctx), 123 + 321 + 333);

License

MIT

FAQs

Package last updated on 31 Jan 2016

Did you know?

Socket

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