Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

safe-evaluate-expression

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-evaluate-expression - npm Package Compare versions

Comparing version 1.4.2 to 1.4.3

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [1.4.3](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.4.2%0Dv1.4.3) (2020-12-03)
### Tests
* add Test case for empty basic rules ([f766774](https://github.com/ttessarolo/safe-evaluate-expression/commits/f7667747967a3124eea8443a663c56d6481904b8))
### [1.4.2](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.4.1%0Dv1.4.2) (2020-12-03)

@@ -7,0 +14,0 @@

2

package.json
{
"name": "safe-evaluate-expression",
"version": "1.4.2",
"version": "1.4.3",
"description": "Small library to dynamically create and evaluate expression with multiple parameters (even undefined)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,8 +17,14 @@ const { FUNC_PARAMS } = require('./factory');

const emptyValues = [
{ value: '', type: 'string' },
{ value: '', type: 'string' },
];
function compose(rule) {
rule = rule.replace(/not /g, '!').trim();
const operator = rule.substring(0, rule.indexOf('('));
const values = rule
.match(FUNC_PARAMS)
.map((value) => ({ value: getValue(value), type: getType(value) }));
const params = rule.match(FUNC_PARAMS);
const values = params
? params.map((value) => ({ value: getValue(value), type: getType(value) }))
: emptyValues;

@@ -25,0 +31,0 @@ return { operator, values };

@@ -13,3 +13,3 @@ const test = require('ava');

'equals(context_device, "desktop") OR equals(context_device, "tablet") AND equals(when_day_of_the_week, "Tuesday") AND greaterThan(now, "21") AND lessThan(now, "23")';
const basic8 = 'condition (equals(, ))';
const c3 = {

@@ -375,2 +375,14 @@ and: [

const c8 = {
and: [
{
operator: 'condition',
values: [
{ value: '', type: 'string' },
{ value: '', type: 'string' },
],
},
],
};
test('test and or condition', (t) => {

@@ -415,1 +427,6 @@ const result = basicToComplex(basic3);

});
test('test basic8', (t) => {
const result = basicToComplex(basic8);
t.deepEqual(result, c8);
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc