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.0 to 1.0.1

2

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

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

@@ -76,3 +76,5 @@ /*

operator = k;
} else if (k.substr(0, 1) !== "$") {
// $ == 36
} else if (k.charCodeAt(0) !== 36) {
operator = "$trav";

@@ -79,0 +81,0 @@ } else {

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

!function(){function n(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 r(){function r(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(r):n}function t(n,t,e){var o=r(e);return{k:t,v:f[n]?f[n](o):o,e:i[n]}}var e=this.test=function(n,t){for(var e=n.exprs,o=0,u=e.length;u>o;o++){var i=e[o];if(!i.e(i.v,r(t),t))return!1}return!0},o=this.parse=function(r,f){r||(r={$eq:r});var s=[];if(r&&r.constructor===Object)for(var a in r){var c;if(i[a])c=a;else{if("$"===a.substr(0,1))throw new Error("Unknown operator "+a+".");c="$trav"}var v=r[a],$=v;if(u[c]){if(~a.indexOf(".")){var l=a.split(".");a=l.shift(),$=v=n(l,v)}if(v instanceof Array){$=[];for(var p=v.length;p--;)$.push(o(v[p]))}else $=o(v,a)}s.push(t(c,a,$))}else s.push(t("$eq",f,r));var d={exprs:s,k:f,test:function(n){return e(d,n)}};return d},u=this.traversable={$and:!0,$or:!0,$nor:!0,$trav:!0,$not:!0},i=this.testers={$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!i.$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,r){for(var t=n.length,o=t;t--;)if(e(n[t],r))return!0;return 0===o},$nor:function(n,r){for(var t=n.length;t--;)if(e(n[t],r))return!1;return!0},$and:function(n,r){for(var t=n.length;t--;)if(!e(n[t],r))return!1;return!0},$trav:function(n,r){if(r instanceof Array){for(var t=r.length;t--;){var o=r[t];if(o[n.k]&&e(n,o[n.k]))return!0}return!1}return e(n,r?r[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)}},f={$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 f.$eq(n)},$where:function(n){return"string"==typeof n?new Function("return "+n):n}}}function t(n,r,t){function u(n){return f.test(i(n))}"object"!=typeof r&&(t=r,r=void 0);var i=o(t),f=e.parse(n);return r?r.filter(u):(u.query=n,u)}var e=new r,o=function(n){if(!n)return function(n){return n};if("function"==typeof n)return n;throw new Error("Unknown sift selector "+n)};t.use=function(n){n.operators&&t.useOperators(n.operators),"function"==typeof n&&n(t)},t.useOperators=function(n){for(var r in n)t.useOperator(r,n[r])},t.useOperator=function(n,r){var t={};t="object"==typeof r?r:{test:r};var o="$"+n;e.testers[o]=t.test,(t.traversable||t.traverse)&&(e.traversable[o]=!0)},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=t:"undefined"!=typeof window&&(window.sift=t)}();
!function(){function n(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 r(){function r(n){return n instanceof Date?n.getTime():n instanceof Array?n.map(r):n}function t(n,t,e){var o=r(e);return{k:t,v:f[n]?f[n](o):o,e:i[n]}}var e=this.test=function(n,t){for(var e=n.exprs,o=0,u=e.length;u>o;o++){var i=e[o];if(!i.e(i.v,r(t),t))return!1}return!0},o=this.parse=function(r,f){r||(r={$eq:r});var a=[];if(r&&r.constructor===Object)for(var s in r){var c;if(i[s])c=s;else{if(36===s.charCodeAt(0))throw new Error("Unknown operator "+s+".");c="$trav"}var v=r[s],$=v;if(u[c]){if(~s.indexOf(".")){var l=s.split(".");s=l.shift(),$=v=n(l,v)}if(v instanceof Array){$=[];for(var p=v.length;p--;)$.push(o(v[p]))}else $=o(v,s)}a.push(t(c,s,$))}else a.push(t("$eq",f,r));var d={exprs:a,k:f,test:function(n){return e(d,n)}};return d},u=this.traversable={$and:!0,$or:!0,$nor:!0,$trav:!0,$not:!0},i=this.testers={$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!i.$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,r){for(var t=n.length,o=t;t--;)if(e(n[t],r))return!0;return 0===o},$nor:function(n,r){for(var t=n.length;t--;)if(e(n[t],r))return!1;return!0},$and:function(n,r){for(var t=n.length;t--;)if(!e(n[t],r))return!1;return!0},$trav:function(n,r){if(r instanceof Array){for(var t=r.length;t--;){var o=r[t];if(o[n.k]&&e(n,o[n.k]))return!0}return!1}return e(n,r?r[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)}},f={$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 f.$eq(n)},$where:function(n){return"string"==typeof n?new Function("return "+n):n}}}function t(n,r,t){function u(n){return f.test(i(n))}"object"!=typeof r&&(t=r,r=void 0);var i=o(t),f=e.parse(n);return r?r.filter(u):(u.query=n,u)}var e=new r,o=function(n){if(!n)return function(n){return n};if("function"==typeof n)return n;throw new Error("Unknown sift selector "+n)};t.use=function(n){n.operators&&t.useOperators(n.operators),"function"==typeof n&&n(t)},t.useOperators=function(n){for(var r in n)t.useOperator(r,n[r])},t.useOperator=function(n,r){var t={};t="object"==typeof r?r:{test:r};var o="$"+n;e.testers[o]=t.test,(t.traversable||t.traverse)&&(e.traversable[o]=!0)},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=t:"undefined"!=typeof window&&(window.sift=t)}();
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