safe-evaluate-expression
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.4.0](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.3.2%0Dv1.4.0) (2020-12-03) | ||
### Features | ||
* dont double-quote when BasicToComples + updated tests ([0301c3a](https://github.com/ttessarolo/safe-evaluate-expression/commits/0301c3abee83a8e54da82a25f47b0065fa6a5519)) | ||
### [1.3.2](https://bitbucket.org/ttessarolo/safe-evaluate-expression/branches/compare/v1.3.1%0Dv1.3.2) (2020-12-03) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "safe-evaluate-expression", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Small library to dynamically create and evaluate expression with multiple parameters (even undefined)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,6 +13,12 @@ const { FUNC_PARAMS } = require('./factory'); | ||
function getValue(value) { | ||
return value.replace(/"/g, '').replace(/'/g, ''); | ||
} | ||
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, type: getType(value) })); | ||
const values = rule | ||
.match(FUNC_PARAMS) | ||
.map((value) => ({ value: getValue(value), type: getType(value) })); | ||
@@ -19,0 +25,0 @@ return { operator, values }; |
@@ -20,7 +20,7 @@ const test = require('ava'); | ||
{ | ||
value: '"k"', | ||
value: 'k', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"z"', | ||
value: 'z', | ||
type: 'string', | ||
@@ -36,7 +36,7 @@ }, | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -50,7 +50,7 @@ }, | ||
{ | ||
value: '"c"', | ||
value: 'c', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"d"', | ||
value: 'd', | ||
type: 'string', | ||
@@ -64,7 +64,7 @@ }, | ||
{ | ||
value: '"e"', | ||
value: 'e', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"f"', | ||
value: 'f', | ||
type: 'string', | ||
@@ -85,7 +85,7 @@ }, | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -99,7 +99,7 @@ }, | ||
{ | ||
value: '"k"', | ||
value: 'k', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"z"', | ||
value: 'z', | ||
type: 'string', | ||
@@ -115,7 +115,7 @@ }, | ||
{ | ||
value: '"c"', | ||
value: 'c', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"d"', | ||
value: 'd', | ||
type: 'string', | ||
@@ -129,7 +129,7 @@ }, | ||
{ | ||
value: '"e"', | ||
value: 'e', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"f"', | ||
value: 'f', | ||
type: 'string', | ||
@@ -150,7 +150,7 @@ }, | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -164,7 +164,7 @@ }, | ||
{ | ||
value: '"c"', | ||
value: 'c', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"d"', | ||
value: 'd', | ||
type: 'string', | ||
@@ -178,7 +178,7 @@ }, | ||
{ | ||
value: '"e"', | ||
value: 'e', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"f"', | ||
value: 'f', | ||
type: 'string', | ||
@@ -192,7 +192,7 @@ }, | ||
{ | ||
value: '"k"', | ||
value: 'k', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"z"', | ||
value: 'z', | ||
type: 'string', | ||
@@ -211,7 +211,7 @@ }, | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -225,7 +225,7 @@ }, | ||
{ | ||
value: '"c"', | ||
value: 'c', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"d"', | ||
value: 'd', | ||
type: 'string', | ||
@@ -239,7 +239,7 @@ }, | ||
{ | ||
value: '"e"', | ||
value: 'e', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"f"', | ||
value: 'f', | ||
type: 'string', | ||
@@ -253,7 +253,7 @@ }, | ||
{ | ||
value: '"k"', | ||
value: 'k', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"z"', | ||
value: 'z', | ||
type: 'string', | ||
@@ -265,3 +265,2 @@ }, | ||
}; | ||
const c0 = { and: [{ operator: '*', values: [] }] }; | ||
@@ -275,7 +274,7 @@ | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -294,7 +293,7 @@ }, | ||
{ | ||
value: '"a"', | ||
value: 'a', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"b"', | ||
value: 'b', | ||
type: 'string', | ||
@@ -308,7 +307,7 @@ }, | ||
{ | ||
value: '"c"', | ||
value: 'c', | ||
type: 'string', | ||
}, | ||
{ | ||
value: '"d"', | ||
value: 'd', | ||
type: 'string', | ||
@@ -331,3 +330,3 @@ }, | ||
{ | ||
value: '"tablet"', | ||
value: 'tablet', | ||
type: 'string', | ||
@@ -345,3 +344,3 @@ }, | ||
{ | ||
value: '"Tuesday"', | ||
value: 'Tuesday', | ||
type: 'string', | ||
@@ -359,3 +358,3 @@ }, | ||
{ | ||
value: '"21"', | ||
value: '21', | ||
type: 'string', | ||
@@ -373,3 +372,3 @@ }, | ||
{ | ||
value: '"23"', | ||
value: '23', | ||
type: 'string', | ||
@@ -389,3 +388,3 @@ }, | ||
{ | ||
value: '"desktop"', | ||
value: 'desktop', | ||
type: 'string', | ||
@@ -403,3 +402,3 @@ }, | ||
{ | ||
value: '"tablet"', | ||
value: 'tablet', | ||
type: 'string', | ||
@@ -406,0 +405,0 @@ }, |
@@ -146,2 +146,3 @@ const test = require('ava'); | ||
const result = complexToBasic(c10); | ||
console.log(JSON.stringify(result, null, 1)); | ||
t.deepEqual(result, b10); | ||
@@ -157,3 +158,3 @@ }); | ||
const result = complexToBasic(c12); | ||
t.deepEqual([], []); | ||
t.deepEqual(result, b12); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50694
981