Socket
Socket
Sign inDemoInstall

sift

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sift - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "sift",
"description": "mongodb query style array filtering",
"version": "2.0.2",
"version": "2.0.3",
"repository": {},

@@ -6,0 +6,0 @@ "engines": {},

@@ -52,2 +52,13 @@ /*

/**
*/
function and(validator) {
return function(a, b) {
if (!isArray(b)) return validator(a, b);
for (var i = 0, n = b.length; i < n; i++) if (!validator(a, b[i])) return false;
return true;
};
}
function validate(validator, b) {

@@ -70,3 +81,3 @@ return validator.v(validator.a, b);

$ne: or(function(a, b) {
$ne: and(function(a, b) {
return !a(b);

@@ -73,0 +84,0 @@ }),

@@ -1,1 +0,1 @@

!function(){"use strict";function n(n){return"function"==typeof n}function t(n){return"[object Array]"===Object.prototype.toString.call(n)}function r(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(r):n}function e(n,t){return n.v(n.a,t)}function u(n,t){for(var r=0;r<n.length;r++)if(e(t,n[r]))return r;return-1}function o(n,t){return{a:n,v:t}}function i(n,t){var r=[];return f(t,n.k,0,r),1===r.length?e(n.nv,r[0]):!!~u(r,n.nv)}function f(n,r,e,u){if(e===r.length||void 0==n)return void u.push(n);if(t(n))for(var o=0,i=n.length;i>o;o++)f(n[o],r,e,u);else f(n[r[e]],r,e+1,u)}function c(n,t){return{a:{k:n,nv:t},v:i}}function a(n){n=r(n),(!n||"Object"!==n.constructor.toString()&&"function Object() { [native code] }"!==n.constructor.toString())&&(n={$eq:n});var t=[];for(var e in n){var u=n[e];if(d[e])l[e]&&(u=l[e](u)),t.push(o(r(u),d[e]));else{if(36===e.charCodeAt(0))throw new Error("Unknown operation "+e);t.push(c(e.split("."),a(u)))}}return 1===t.length?t[0]:o(t,d.$and)}function $(n,t){var r=a(n);return t&&(r={a:r,v:function(n,r){return e(n,t(r))}}),r}function s(t,r,u){function o(n){return e(i,n)}n(r)&&(u=r,r=void 0);var i=$(t,u);return r?r.filter(o):o}var d={$eq:function(n,t){return n(t)},$ne:function(n,t){return!n(t)},$or:function(n,t){for(var r=0,u=n.length;u>r;r++)if(e(n[r],t))return!0;return!1},$gt:function(n,t){return r(t)>n},$gte:function(n,t){return r(t)>=n},$lt:function(n,t){return r(t)<n},$lte:function(n,t){return r(t)<=n},$mod:function(n,t){return t%n[0]==n[1]},$in:function(n,t){if(!(t instanceof Array))return!!~n.indexOf(r(t));for(var e=t.length;e--;)if(~n.indexOf(r(t[e])))return!0;return!1},$nin:function(n,t){return!d.$in(n,t)},$not:function(n,t){return!e(n,t)},$type:function(n,t){return void 0!=t?t instanceof n||t.constructor==n:!1},$all:function(n,t){t||(t=[]);for(var e=n.length;e--;)if(!~r(t).indexOf(n[e]))return!1;return!0},$size:function(n,t){return t?n===t.length:!1},$nor:function(n,t){for(var r=0,u=n.length;u>r;r++)if(e(n[r],t))return!1;return!0},$and:function(n,t){for(var r=0,u=n.length;u>r;r++)if(!e(n[r],t))return!1;return!0},$regex:function(n,t){return n.test(t)},$where:function(n,t){return n.call(t,t)},$elemMatch:function(n,r){return t(r)?!!~u(r,n):e(n,r)},$exists:function(n,t){return void 0!=t===n}},l={$eq:function(n){return n instanceof RegExp?function(t){return n.test(r(t))}:n instanceof Function?n:function(t){return t instanceof Array?~r(t).indexOf(n):n===r(t)}},$ne:function(n){return l.$eq(n)},$and:function(n){return n.map(a)},$or:function(n){return n.map(a)},$nor:function(n){return n.map(a)},$not:function(n){return a(n)},$regex:function(n){return new RegExp(n)},$where:function(n){return"string"==typeof n?new Function("obj","return "+n):n},$elemMatch:function(n){return a(n)},$exists:function(n){return!!n}};s.use=function(t){if(n(t))return t(s);for(var r in t)36===r.charCodeAt(0)&&(d[r]=t[r])},s.indexOf=function(n,t,r){return u(t,$(n,r))},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=s:"undefined"!=typeof window&&(window.sift=s)}();
!function(){"use strict";function n(n){return"function"==typeof n}function t(n){return"[object Array]"===Object.prototype.toString.call(n)}function r(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(r):n}function e(n){return function(r,e){if(!t(e))return n(r,e);for(var u=0,o=e.length;o>u;u++)if(n(r,e[u]))return!0;return!1}}function u(n){return function(r,e){if(!t(e))return n(r,e);for(var u=0,o=e.length;o>u;u++)if(!n(r,e[u]))return!1;return!0}}function o(n,t){return n.v(n.a,t)}function i(n,t){for(var r=0;r<n.length;r++)if(o(t,n[r]))return r;return-1}function f(n,t){return{a:n,v:t}}function c(n,t){var r=[];return a(t,n.k,0,r),1===r.length?o(n.nv,r[0]):!!~i(r,n.nv)}function a(n,r,e,u){if(e===r.length||void 0==n)return void u.push(n);if(t(n))for(var o=0,i=n.length;i>o;o++)a(n[o],r,e,u);else a(n[r[e]],r,e+1,u)}function $(n,t){return{a:{k:n,nv:t},v:c}}function l(n){n=r(n),(!n||"Object"!==n.constructor.toString()&&"function Object() { [native code] }"!==n.constructor.toString())&&(n={$eq:n});var t=[];for(var e in n){var u=n[e];if(d[e])g[e]&&(u=g[e](u)),t.push(f(r(u),d[e]));else{if(36===e.charCodeAt(0))throw new Error("Unknown operation "+e);t.push($(e.split("."),l(u)))}}return 1===t.length?t[0]:f(t,d.$and)}function v(n,t){var r=l(n);return t&&(r={a:r,v:function(n,r){return o(n,t(r))}}),r}function s(t,r,e){function u(n){return o(i,n)}n(r)&&(e=r,r=void 0);var i=v(t,e);return r?r.filter(u):u}var d={$eq:e(function(n,t){return n(t)}),$ne:u(function(n,t){return!n(t)}),$or:function(n,t){for(var r=0,e=n.length;e>r;r++)if(o(n[r],t))return!0;return!1},$gt:e(function(n,t){return r(t)>n}),$gte:e(function(n,t){return r(t)>=n}),$lt:e(function(n,t){return r(t)<n}),$lte:e(function(n,t){return r(t)<=n}),$mod:e(function(n,t){return t%n[0]==n[1]}),$in:function(n,t){if(!(t instanceof Array))return!!~n.indexOf(r(t));for(var e=t.length;e--;)if(~n.indexOf(r(t[e])))return!0;return!1},$nin:function(n,t){return!d.$in(n,t)},$not:function(n,t){return!o(n,t)},$type:function(n,t){return void 0!=t?t instanceof n||t.constructor==n:!1},$all:function(n,t){t||(t=[]);for(var e=n.length;e--;)if(!~r(t).indexOf(n[e]))return!1;return!0},$size:function(n,t){return t?n===t.length:!1},$nor:function(n,t){for(var r=0,e=n.length;e>r;r++)if(o(n[r],t))return!1;return!0},$and:function(n,t){for(var r=0,e=n.length;e>r;r++)if(!o(n[r],t))return!1;return!0},$regex:function(n,t){return n.test(t)},$where:function(n,t){return n.call(t,t)},$elemMatch:function(n,r){return t(r)?!!~i(r,n):o(n,r)},$exists:function(n,t){return void 0!=t===n}},g={$eq:function(n){return n instanceof RegExp?function(t){return n.test(r(t))}:n instanceof Function?n:function(t){return n===r(t)}},$ne:function(n){return g.$eq(n)},$and:function(n){return n.map(l)},$or:function(n){return n.map(l)},$nor:function(n){return n.map(l)},$not:function(n){return l(n)},$regex:function(n){return new RegExp(n)},$where:function(n){return"string"==typeof n?new Function("obj","return "+n):n},$elemMatch:function(n){return l(n)},$exists:function(n){return!!n}};s.use=function(t){if(n(t))return t(s);for(var r in t)36===r.charCodeAt(0)&&(d[r]=t[r])},s.indexOf=function(n,t,r){return i(t,v(n,r))},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=s:"undefined"!=typeof window&&(window.sift=s)}();

@@ -36,2 +36,3 @@ var assert = require("assert");

[{$ne:1}, [[2],[1]], [[2]]],
[{groups:{$ne:111}}, [{groups:[111,222,333,444]},{groups:[222,333,444]}],[{groups:[222,333,444]}]],

@@ -38,0 +39,0 @@ // $lt

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