🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

node-expr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-expr

Javascript expression evaluator

0.0.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

expr

Build Status

expr is a simple and secure Javascript expression evaluator. Useful for evaluating dinamically generated expressions.

Usage

Evaluating an expression against objects


var str = "this.age > 30 && this.gender === 'female'";

var expr = new expr.Expr(str);

expr.test({ age: 15, gender: 'male' });
// => false

expr.test({ age: 32, gender: 'female' });
// => true

Evaluating an object against expressions


var ctx = new expr.Ctx({ age: 15, gender: 'male' });

ctx.match("this.age > 30 && this.gender === 'female'");
// => false

ctx.match("this.age > 10 && this.gender === 'male'");
// => true

Keywords

eval

FAQs

Package last updated on 05 Jun 2014

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