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.7.0 to 1.7.1

7

CHANGELOG.md

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

### [1.7.1](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.7.0%0Dv1.7.1) (2020-12-30)
### Bug Fixes
* complex2Basic now correctly handle one value expression ([f304643](https://github.com/ttessarolo/safe-evaluate-expression/commits/f30464307766842e65b9e85c760be6a04e99e0f7))
## [1.7.0](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.6.1%0Dv1.7.0) (2020-12-10)

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

12

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

@@ -43,3 +43,3 @@ "main": "index.js",

"devDependencies": {
"ava": "^3.13.0",
"ava": "^3.14.0",
"codecov": "^3.8.1",

@@ -49,10 +49,10 @@ "commitizen": "^4.2.2",

"deep-cleaner": "^1.2.1",
"eslint": "^7.2.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.0.0",
"husky": "^4.3.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^4.3.5",
"nyc": "^15.1.0",

@@ -59,0 +59,0 @@ "standard-version": "^9.0.0"

function getValue(data) {
return data.value;
// let value = data.value;
// if (['string', 'freeText'].includes(data.type)) {
// if (value.toString().match(/"/)) {
// value = `"${value}"`;
// }
// }
}
// return value;
}
function complexToBasic(rule) {

@@ -17,3 +10,6 @@ const result = (rule.and || rule.or)

if (sub.and || sub.or) return complexToBasic(sub);
return `${sub.operator}(${sub.values.map((v) => getValue(v)).join(', ')})`;
return `${sub.operator}(${sub.values
.map((v) => getValue(v))
.filter((v) => v)
.join(', ')})`;
})

@@ -20,0 +16,0 @@ .join(rule.and ? ' && ' : ' || ');

@@ -139,2 +139,12 @@ const test = require('ava');

c13 = {
and: [
{
operator: 'isEmpty',
values: [{ type: 'metadata', value: 'query_title' }, { value: '' }],
id: 'EybWr2jujI',
},
],
};
const b10 = `(((isEqual(dayOfTheWeek, "Lun") && (isGreater(hourOfDay, 10) && isLess(hourOfDay, 12))) || (isEqual(dayOfTheWeek, "Ven") && (isGreater(hourOfDay, 20) && isLess(hourOfDay, 23)))) && isEqual(recommendable, true))`;

@@ -144,2 +154,3 @@ const c11 = { and: [{ operator: '*' }] };

const b12 = `(isEqual("k", "z") && (!isEmpty("a", "b") || isEqual("c", "d") || isEqual("e", "f")))`;
const b13 = `(isEmpty(query_title))`;

@@ -160,1 +171,6 @@ test('test deep nested condition', (t) => {

});
test('test one value condition', (t) => {
const result = complexToBasic(c13);
t.deepEqual(result, b13);
});
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