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

@allbin/entity-logic

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allbin/entity-logic - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

20

lib/index.test.js

@@ -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 () {

32

lib/operators.js

@@ -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",

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