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 1.0.6 to 1.1.0

2

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

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

@@ -224,2 +224,9 @@ /*

return a.call(b, b);
},
/**
*/
$elemMatch: function (a, b) {
return a.test(b);
}

@@ -273,2 +280,9 @@ };

return a;
},
/**
*/
$elemMatch: function (a) {
return parse(a);
}

@@ -275,0 +289,0 @@ };

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

!function(){"use strict";function n(n,r,t){var o=e(t);return{k:r,v:c[n]?c[n](o):o,e:a[n]}}function r(n,r){for(var t=n.exprs,o=0,u=t.length;u>o;o++){var i=t[o];if(!i.e(i.v,e(r),r))return!1}return!0}function t(e,u){e||(e={$eq:e});var i=[];if(e&&e.constructor===Object)for(var c in e){var s;if(a[c])s=c;else{if(36===c.charCodeAt(0))throw new Error("Unknown operator "+c+".");s="$trav"}var v=e[c],$=v;if(f[s]){if(~c.indexOf(".")){var l=c.split(".");c=l.shift(),$=v=o(l,v)}if(v instanceof Array){$=[];for(var p=v.length;p--;)$.push(t(v[p]))}else $=t(v,c)}i.push(n(s,c,$))}else i.push(n("$eq",u,e));var d={exprs:i,k:u,test:function(n){return r(d,n)}};return d}function e(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(e):n}function o(n,r){for(var t={},e=t,o=0,u=n.length-1;u>o;o++)e=e[n[o]]={};return e[n[o]]=r,t}function u(n){if(!n)return function(n){return n};if("function"==typeof n)return n;throw new Error("Unknown sift selector "+n)}function i(n,r,e){function o(n){return f.test(i(n))}"object"!=typeof r&&(e=r,r=void 0);var i=u(e),f=t(n);return r?r.filter(o):(o.query=n,o)}var f={$and:!0,$or:!0,$nor:!0,$trav:!0,$not:!0},a={$eq:function(n,r){return n.test(r)},$ne:function(n,r){return!n.test(r)},$lt:function(n,r){return n>r},$gt:function(n,r){return r>n},$lte:function(n,r){return n>=r},$gte:function(n,r){return r>=n},$exists:function(n,r){return n===(null!=r)},$in:function(n,r){if(!(r instanceof Array))return~n.indexOf(r);for(var t=r.length;t--;)if(~n.indexOf(r[t]))return!0;return!1},$not:function(n,r){if(!n.test)throw new Error("$not test should include an expression, not a value. Use $ne instead.");return!n.test(r)},$type:function(n,r,t){return null!=t?t instanceof n||t.constructor==n:!1},$nin:function(n,r){return!a.$in(n,r)},$mod:function(n,r){return r%n[0]==n[1]},$all:function(n,r){r||(r=[]);for(var t=n.length;t--;){var e=n[t],o=~r.indexOf(e);if(!o)return!1}return!0},$size:function(n,r){return r?n===r.length:!1},$or:function(n,t){for(var e=n.length,o=e;e--;)if(r(n[e],t))return!0;return 0===o},$nor:function(n,t){for(var e=n.length;e--;)if(r(n[e],t))return!1;return!0},$and:function(n,t){for(var e=n.length;e--;)if(!r(n[e],t))return!1;return!0},$trav:function(n,t){if(t instanceof Array){for(var e=t.length;e--;){var o=t[e];if(o[n.k]&&r(n,o[n.k]))return!0}return!1}return r(n,t?t[n.k]:void 0)},$regex:function(n,r){var t=new RegExp(n);return t.test(r)},$where:function(n,r){return n.call(r,r)}},c={$eq:function(n){var r;return n instanceof RegExp?n:(r=n instanceof Function?n:function(r){return r instanceof Array?~r.indexOf(n):n===r},{test:r})},$ne:function(n){return c.$eq(n)},$where:function(n){return"string"==typeof n?new Function("obj","return "+n):n}};i.use=function(n){n.operators&&i.useOperators(n.operators),"function"==typeof n&&n(i)},i.useOperators=function(n){for(var r in n)i.useOperator(r,n[r])},i.useOperator=function(n,r){var t={};t="object"==typeof r?r:{test:r};var e="$"+n;a[e]=t.test,(t.traversable||t.traverse)&&(f[e]=!0)},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=i:"undefined"!=typeof window&&(window.sift=i)}();
!function(){"use strict";function n(n,r,t){var o=e(t);return{k:r,v:a[n]?a[n](o):o,e:c[n]}}function r(n,r){for(var t=n.exprs,o=0,u=t.length;u>o;o++){var i=t[o];if(!i.e(i.v,e(r),r))return!1}return!0}function t(e,u){e||(e={$eq:e});var i=[];if(e&&e.constructor===Object)for(var a in e){var s;if(c[a])s=a;else{if(36===a.charCodeAt(0))throw new Error("Unknown operator "+a+".");s="$trav"}var $=e[a],v=$;if(f[s]){if(~a.indexOf(".")){var l=a.split(".");a=l.shift(),v=$=o(l,$)}if($ instanceof Array){v=[];for(var p=$.length;p--;)v.push(t($[p]))}else v=t($,a)}i.push(n(s,a,v))}else i.push(n("$eq",u,e));var d={exprs:i,k:u,test:function(n){return r(d,n)}};return d}function e(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(e):n}function o(n,r){for(var t={},e=t,o=0,u=n.length-1;u>o;o++)e=e[n[o]]={};return e[n[o]]=r,t}function u(n){if(!n)return function(n){return n};if("function"==typeof n)return n;throw new Error("Unknown sift selector "+n)}function i(n,r,e){function o(n){return f.test(i(n))}"object"!=typeof r&&(e=r,r=void 0);var i=u(e),f=t(n);return r?r.filter(o):(o.query=n,o)}var f={$and:!0,$or:!0,$nor:!0,$trav:!0,$not:!0},c={$eq:function(n,r){return n.test(r)},$ne:function(n,r){return!n.test(r)},$lt:function(n,r){return n>r},$gt:function(n,r){return r>n},$lte:function(n,r){return n>=r},$gte:function(n,r){return r>=n},$exists:function(n,r){return n===(null!=r)},$in:function(n,r){if(!(r instanceof Array))return~n.indexOf(r);for(var t=r.length;t--;)if(~n.indexOf(r[t]))return!0;return!1},$not:function(n,r){if(!n.test)throw new Error("$not test should include an expression, not a value. Use $ne instead.");return!n.test(r)},$type:function(n,r,t){return null!=t?t instanceof n||t.constructor==n:!1},$nin:function(n,r){return!c.$in(n,r)},$mod:function(n,r){return r%n[0]==n[1]},$all:function(n,r){r||(r=[]);for(var t=n.length;t--;){var e=n[t],o=~r.indexOf(e);if(!o)return!1}return!0},$size:function(n,r){return r?n===r.length:!1},$or:function(n,t){for(var e=n.length,o=e;e--;)if(r(n[e],t))return!0;return 0===o},$nor:function(n,t){for(var e=n.length;e--;)if(r(n[e],t))return!1;return!0},$and:function(n,t){for(var e=n.length;e--;)if(!r(n[e],t))return!1;return!0},$trav:function(n,t){if(t instanceof Array){for(var e=t.length;e--;){var o=t[e];if(o[n.k]&&r(n,o[n.k]))return!0}return!1}return r(n,t?t[n.k]:void 0)},$regex:function(n,r){var t=new RegExp(n);return t.test(r)},$where:function(n,r){return n.call(r,r)},$elemMatch:function(n,r){return n.test(r)}},a={$eq:function(n){var r;return n instanceof RegExp?n:(r=n instanceof Function?n:function(r){return r instanceof Array?~r.indexOf(n):n===r},{test:r})},$ne:function(n){return a.$eq(n)},$where:function(n){return"string"==typeof n?new Function("obj","return "+n):n},$elemMatch:function(n){return t(n)}};i.use=function(n){n.operators&&i.useOperators(n.operators),"function"==typeof n&&n(i)},i.useOperators=function(n){for(var r in n)i.useOperator(r,n[r])},i.useOperator=function(n,r){var t={};t="object"==typeof r?r:{test:r};var e="$"+n;c[e]=t.test,(t.traversable||t.traverse)&&(f[e]=!0)},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=i:"undefined"!=typeof window&&(window.sift=i)}();

@@ -105,4 +105,8 @@ var assert = require("assert");

[{$where:"this.v === 1"}, [{v:1},{v:2}],[{v:1}]],
[{$where:"obj.v === 1"}, [{v:1},{v:2}],[{v:1}]]
[{$where:"obj.v === 1"}, [{v:1},{v:2}],[{v:1}]],
// $elemMatch
[{a:{$elemMatch:{b:1,c:2}}}, [{a:{b:1,c:2}},{a:{b:1,c:2,d:3}},{a:{b:2,c:3}}], [{a:{b:1,c:2}},{a:{b:1,c:2,d:3}}]],
[{a:{$elemMatch:{b:2,c:{$gt:2}}}}, [{a:{b:1,c:2}},{a:{b:1,c:2,d:3}},{a:{b:2,c:3}}], [{a:{b:2,c:3}}]],
].forEach(function (operation) {

@@ -109,0 +113,0 @@

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