@allbin/entity-logic
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -328,2 +328,22 @@ "use strict"; | ||
}); | ||
it('correctly executes number.none_of conditions', function () { | ||
var condition = { | ||
field: 'inventory.2', | ||
type: 'number', | ||
operator: 'none_of', | ||
value: [1, 2], | ||
}; | ||
var result = entityLogic.execute(entities, [condition]); | ||
expect(result).toMatchObject([numberZeroEntity]); | ||
}); | ||
it('correctly executes number.any_of conditions', function () { | ||
var condition = { | ||
field: 'inventory.2', | ||
type: 'number', | ||
operator: 'any_of', | ||
value: [1, 2], | ||
}; | ||
var result = entityLogic.execute(entities, [condition]); | ||
expect(result).toMatchObject([numberOneEntity]); | ||
}); | ||
}); | ||
@@ -330,0 +350,0 @@ describe('string operators', function () { |
@@ -124,2 +124,18 @@ "use strict"; | ||
}, | ||
none_of: { | ||
params: ['array:number'], | ||
func: function (field, vals) { return function (entity, prop_val) { | ||
return Array.isArray(vals) && | ||
typeof prop_val === 'number' && | ||
!vals.some(function (v) { return v === prop_val; }); | ||
}; }, | ||
}, | ||
any_of: { | ||
params: ['array:number'], | ||
func: function (field, vals) { return function (entity, prop_val) { | ||
return Array.isArray(vals) && | ||
typeof prop_val === 'number' && | ||
vals.some(function (v) { return v === prop_val; }); | ||
}; }, | ||
}, | ||
}, | ||
@@ -171,3 +187,3 @@ string: { | ||
}, | ||
any_of: { | ||
none_of: { | ||
params: ['array:string'], | ||
@@ -177,8 +193,8 @@ func: function (field, vals) { return function (entity, prop_val) { | ||
typeof prop_val === 'string' && | ||
vals.find(function (v) { | ||
!vals.some(function (v) { | ||
return typeof v === 'string' && v.toLowerCase() === prop_val.toLowerCase(); | ||
}) !== undefined; | ||
}); | ||
}; }, | ||
}, | ||
none_of: { | ||
any_of: { | ||
params: ['array:string'], | ||
@@ -188,5 +204,5 @@ func: function (field, vals) { return function (entity, prop_val) { | ||
typeof prop_val === 'string' && | ||
vals.find(function (v) { | ||
vals.some(function (v) { | ||
return typeof v === 'string' && v.toLowerCase() === prop_val.toLowerCase(); | ||
}) === undefined; | ||
}); | ||
}; }, | ||
@@ -356,3 +372,3 @@ }, | ||
Array.isArray(vals) && | ||
vals.find(function (v) { return prop_vals.includes(v); }) === undefined; | ||
!vals.some(function (v) { return prop_vals.includes(v); }); | ||
}; }, | ||
@@ -399,3 +415,3 @@ }, | ||
Array.isArray(vals) && | ||
vals.find(function (v) { return prop_vals.includes(v); }) === undefined; | ||
!vals.some(function (v) { return prop_vals.includes(v); }); | ||
}; }, | ||
@@ -402,0 +418,0 @@ }, |
@@ -52,3 +52,3 @@ import { DateTime } from 'luxon'; | ||
type: 'number'; | ||
operator: 'between' | 'not_between'; | ||
operator: 'between' | 'not_between' | 'none_of' | 'any_of'; | ||
value: number[]; | ||
@@ -55,0 +55,0 @@ } |
{ | ||
"name": "@allbin/entity-logic", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Logic solver for mobilix filters", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
64219
1718