sift
Advanced tools
Comparing version 11.1.8 to 12.0.0
@@ -0,1 +1,5 @@ | ||
## 12.0.0 | ||
- Fix bug where \$elemMatch tested objects: e.g: `sift({a: {$elemMatch: 1}})({ a: { b: 1}})`. \$elemMatch now expects arrays based on Mongodb syntax. E.g: `sift({a: {$elemMatch: 1}})({ a: { b: 1}})` | ||
## 11.0.0 | ||
@@ -2,0 +6,0 @@ |
@@ -14,9 +14,2 @@ var __extends = (this && this.__extends) || (function () { | ||
})(); | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
import { isArray, isVanillaObject, comparable, equals } from "./utils"; | ||
@@ -96,2 +89,3 @@ /** | ||
} | ||
// console.log("DONE", this.params, done, success); | ||
this.done = done; | ||
@@ -220,5 +214,7 @@ this.success = success; | ||
var _a = createQueryOperations(query, options), selfOperations = _a[0], nestedOperations = _a[1]; | ||
var ops = __spreadArrays([ | ||
new NestedOperation([], query, owneryQuery, options, selfOperations) | ||
], nestedOperations); | ||
var ops = []; | ||
if (selfOperations.length) { | ||
ops.push(new NestedOperation([], query, owneryQuery, options, selfOperations)); | ||
} | ||
ops.push.apply(ops, nestedOperations); | ||
if (ops.length === 1) { | ||
@@ -225,0 +221,0 @@ return ops[0]; |
@@ -16,2 +16,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { comparable, isFunction } from "./utils"; | ||
import { isArray } from "util"; | ||
var $Ne = /** @class */ (function (_super) { | ||
@@ -37,2 +38,3 @@ __extends($Ne, _super); | ||
}(BaseOperation)); | ||
// https://docs.mongodb.com/manual/reference/operator/query/elemMatch/ | ||
var $ElemMatch = /** @class */ (function (_super) { | ||
@@ -50,5 +52,12 @@ __extends($ElemMatch, _super); | ||
$ElemMatch.prototype.next = function (item, key, owner) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = this._queryOperation.success; | ||
this._queryOperation.reset(); | ||
if (isArray(owner)) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done || key === owner.length - 1; | ||
this.success = this._queryOperation.success; | ||
} | ||
else { | ||
this.done = true; | ||
this.success = false; | ||
} | ||
}; | ||
@@ -62,8 +71,15 @@ return $ElemMatch; | ||
} | ||
$Not.prototype.init = function () { | ||
this._queryOperation = createQueryOperation(this.params, this.owneryQuery, this.options); | ||
}; | ||
$Not.prototype.reset = function () { | ||
this._queryOperation.reset(); | ||
}; | ||
$Not.prototype.next = function (item, key, owner) { | ||
_super.prototype.next.call(this, item, key, owner); | ||
this.success = !this.success; | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = !this._queryOperation.success; | ||
}; | ||
return $Not; | ||
}($ElemMatch)); | ||
}(BaseOperation)); | ||
var $Or = /** @class */ (function (_super) { | ||
@@ -70,0 +86,0 @@ __extends($Or, _super); |
@@ -39,3 +39,3 @@ import { Key, Comparator } from "./utils"; | ||
export declare abstract class GroupOperation extends BaseOperation<any> { | ||
private readonly _children; | ||
protected readonly _children: Operation[]; | ||
success: boolean; | ||
@@ -42,0 +42,0 @@ done: boolean; |
@@ -15,9 +15,2 @@ "use strict"; | ||
})(); | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -98,2 +91,3 @@ var utils_1 = require("./utils"); | ||
} | ||
// console.log("DONE", this.params, done, success); | ||
this.done = done; | ||
@@ -222,5 +216,7 @@ this.success = success; | ||
var _a = createQueryOperations(query, options), selfOperations = _a[0], nestedOperations = _a[1]; | ||
var ops = __spreadArrays([ | ||
new NestedOperation([], query, owneryQuery, options, selfOperations) | ||
], nestedOperations); | ||
var ops = []; | ||
if (selfOperations.length) { | ||
ops.push(new NestedOperation([], query, owneryQuery, options, selfOperations)); | ||
} | ||
ops.push.apply(ops, nestedOperations); | ||
if (ops.length === 1) { | ||
@@ -227,0 +223,0 @@ return ops[0]; |
@@ -11,7 +11,11 @@ import { BaseOperation, EqualsOperation, Options, Operation, Query, GroupOperation } from "./core"; | ||
private _queryOperation; | ||
private _current; | ||
init(): void; | ||
reset(): void; | ||
next(item: any, key: Key, owner: any): void; | ||
next(item: any, key: Key, owner: any[]): void; | ||
} | ||
declare class $Not extends $ElemMatch { | ||
declare class $Not extends BaseOperation<Query> { | ||
private _queryOperation; | ||
init(): void; | ||
reset(): void; | ||
next(item: any, key: Key, owner: any): void; | ||
@@ -18,0 +22,0 @@ } |
@@ -18,2 +18,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var util_1 = require("util"); | ||
var $Ne = /** @class */ (function (_super) { | ||
@@ -39,2 +40,3 @@ __extends($Ne, _super); | ||
}(core_1.BaseOperation)); | ||
// https://docs.mongodb.com/manual/reference/operator/query/elemMatch/ | ||
var $ElemMatch = /** @class */ (function (_super) { | ||
@@ -52,5 +54,12 @@ __extends($ElemMatch, _super); | ||
$ElemMatch.prototype.next = function (item, key, owner) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = this._queryOperation.success; | ||
this._queryOperation.reset(); | ||
if (util_1.isArray(owner)) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done || key === owner.length - 1; | ||
this.success = this._queryOperation.success; | ||
} | ||
else { | ||
this.done = true; | ||
this.success = false; | ||
} | ||
}; | ||
@@ -64,8 +73,15 @@ return $ElemMatch; | ||
} | ||
$Not.prototype.init = function () { | ||
this._queryOperation = core_1.createQueryOperation(this.params, this.owneryQuery, this.options); | ||
}; | ||
$Not.prototype.reset = function () { | ||
this._queryOperation.reset(); | ||
}; | ||
$Not.prototype.next = function (item, key, owner) { | ||
_super.prototype.next.call(this, item, key, owner); | ||
this.success = !this.success; | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = !this._queryOperation.success; | ||
}; | ||
return $Not; | ||
}($ElemMatch)); | ||
}(core_1.BaseOperation)); | ||
var $Or = /** @class */ (function (_super) { | ||
@@ -72,0 +88,0 @@ __extends($Or, _super); |
{ | ||
"name": "sift", | ||
"description": "mongodb query style array filtering", | ||
"version": "11.1.8", | ||
"version": "12.0.0", | ||
"repository": "crcn/sift.js", | ||
@@ -30,2 +30,3 @@ "sideEffects": false, | ||
"mocha": "^5.2.0", | ||
"mongodb": "^3.5.5", | ||
"prettier": "1.15.3", | ||
@@ -48,5 +49,5 @@ "pretty-quick": "^1.11.1", | ||
"build:watch": "tsc --watch", | ||
"test": "mocha ./test -R spec --compilers \"js:@babel/register\"", | ||
"test": "mocha ./test -R spec", | ||
"prepublishOnly": "npm run build && npm run test" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sift=n():t.sift=n()}(this,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=3)}([function(t,n,e){"use strict";var r,o=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(n,"__esModule",{value:!0});var i=e(1),u=e(2),s=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._test=i.createTester(this.params,this.options.compare)},n.prototype.reset=function(){t.prototype.reset.call(this),this.success=!0},n.prototype.next=function(t){this._test(t)&&(this.done=!0,this.success=!1)},n}(i.BaseOperation),c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},n.prototype.reset=function(){this._queryOperation.reset()},n.prototype.next=function(t,n,e){this._queryOperation.next(t,n,e),this.done=this._queryOperation.done,this.success=this._queryOperation.success},n}(i.BaseOperation),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(n,e,r){t.prototype.next.call(this,n,e,r),this.success=!this.success},n}(c),p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){var t=this;this._ops=this.params.map((function(n){return i.createQueryOperation(n,null,t.options)}))},n.prototype.reset=function(){this.done=!1,this.success=!1;for(var t=0,n=this._ops.length;t<n;t++)this._ops[t].reset()},n.prototype.next=function(t,n,e){for(var r=!1,o=!1,i=0,u=this._ops.length;i<u;i++){var s=this._ops[i];if(s.next(t,n,e),s.success){r=!0,o=s.success;break}}this.success=o,this.done=r},n}(i.BaseOperation),f=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(n,e,r){t.prototype.next.call(this,n,e,r),this.success=!this.success},n}(p),l=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(t,n,e){e.hasOwnProperty(n)===this.params&&(this.done=!0,this.success=!0)},n}(i.BaseOperation),h=function(t){function n(n,e,r){return t.call(this,n,e,r,n.map((function(t){return i.createQueryOperation(t,e,r)})))||this}return o(n,t),n.prototype.next=function(t,n,e){this.childrenNext(t,n,e)},n}(i.GroupOperation);n.$eq=function(t,n,e){return new i.EqualsOperation(t,n,e)},n.$ne=function(t,n,e){return new s(t,n,e)},n.$or=function(t,n,e){return new p(t,n,e)},n.$nor=function(t,n,e){return new f(t,n,e)},n.$elemMatch=function(t,n,e){return new c(t,n,e)},n.$nin=function(t,n,e){return new f(t,n,e)},n.$in=function(t,n,e){return new p(t,n,e)},n.$lt=i.numericalOperation((function(t){return function(n){return n<t}})),n.$lte=i.numericalOperation((function(t){return function(n){return n<=t}})),n.$gt=i.numericalOperation((function(t){return function(n){return n>t}})),n.$gte=i.numericalOperation((function(t){return function(n){return n>=t}})),n.$mod=function(t,n,e){var r=t[0],o=t[1];return new i.EqualsOperation((function(t){return u.comparable(t)%r===o}),n,e)},n.$exists=function(t,n,e){return new l(t,n,e)},n.$regex=function(t,n,e){return new i.EqualsOperation(new RegExp(t,n.$options),n,e)},n.$not=function(t,n,e){return new a(t,n,e)},n.$type=function(t,n,e){return new i.EqualsOperation((function(n){return null!=n&&(n instanceof t||n.constructor===t)}),n,e)},n.$and=function(t,n,e){return new h(t,n,e)},n.$all=n.$and,n.$size=function(t,n,e){return new i.EqualsOperation((function(n){return n&&n.length===t}),n,e)},n.$options=function(){return null},n.$where=function(t,n,e){var r;if(!u.isFunction(t))throw new Error('In CSP mode, sift does not support strings in "$where" condition');return r=t,new i.EqualsOperation((function(t){return r.bind(t)(t)}),n,e)}},function(t,n,e){"use strict";var r,o=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),i=this&&this.__spreadArrays||function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var r=Array(t),o=0;for(n=0;n<e;n++)for(var i=arguments[n],u=0,s=i.length;u<s;u++,o++)r[o]=i[u];return r};Object.defineProperty(n,"__esModule",{value:!0});var u=e(2),s=function(t,n,e,r,o,i){var c=n[r];if(u.isArray(t)&&isNaN(Number(c)))for(var a=0,p=t.length;a<p;a++)if(!s(t[a],n,e,r,a,t))return!1;return r===n.length||null==t?e(t,o,i):s(t[c],n,e,r+1,c,t)},c=function(){function t(t,n,e){this.params=t,this.owneryQuery=n,this.options=e,this.init()}return t.prototype.init=function(){},t.prototype.reset=function(){this.done=!1,this.success=!1},t}();n.BaseOperation=c;var a=function(t){function n(n,e,r,o){var i=t.call(this,n,e,r)||this;return i._children=o,i}return o(n,t),n.prototype.reset=function(){this.success=!1,this.done=!1;for(var t=0,n=this._children.length;t<n;t++)this._children[t].reset()},n.prototype.childrenNext=function(t,n,e){for(var r=!0,o=!0,i=0,u=this._children.length;i<u;i++){var s=this._children[i];if(s.next(t,n,e),s.success||(o=!1),s.done){if(!s.success)break}else r=!1}this.done=r,this.success=o},n}(c);n.GroupOperation=a;var p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(t,n,e){this.childrenNext(t,n,e)},n}(a);n.QueryOperation=p;var f=function(t){function n(n,e,r,o,i){var u=t.call(this,e,r,o,i)||this;return u.keyPath=n,u._nextNestedValue=function(t,n,e){return u.childrenNext(t,n,e),!u.done},u}return o(n,t),n.prototype.next=function(t,n,e){s(t,this.keyPath,this._nextNestedValue,0,n,e)},n}(a);n.NestedOperation=f,n.createTester=function(t,n){if(t instanceof Function)return t;if(t instanceof RegExp)return function(n){return"string"==typeof n&&t.test(n)};var e=u.comparable(t);return function(t){return n(e,u.comparable(t))}};var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._test=n.createTester(this.params,this.options.compare)},e.prototype.next=function(t,n,e){this._test(t,n,e)&&(this.done=!0,this.success=!0)},e}(c);n.EqualsOperation=l,n.createEqualsOperation=function(t,n,e){return new l(t,n,e)};var h=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(){this.done=!0,this.success=!1},n}(c);n.NopeOperation=h,n.numericalOperationCreator=function(t){return function(n,e,r){return null==n?new h(n,e,r):t(n,e,r)}},n.numericalOperation=function(t){return n.numericalOperationCreator((function(n,e,r){var o=typeof u.comparable(n),i=t(n);return new l((function(t){return typeof u.comparable(t)===o&&i(t)}),e,r)}))};var y=function(t,n,e,r){var o=r.operations[t];if(!o)throw new Error("Unsupported operation: "+t);return o(n,e,r)},O=function(t,n,e,r){if(function(t){for(var n in t)if("$"===n.charAt(0))return!0;return!1}(n)){var o=d(n,r),i=o[0];if(o[1].length)throw new Error("Property queries must contain only operations, or exact objects.");return new f(t,n,e,r,i)}return new f(t,n,e,r,[new l(n,e,r)])};n.createQueryOperation=function(t,n,e){var r=d(t,e),o=r[0],u=r[1],s=i([new f([],t,n,e,o)],u);return 1===s.length?s[0]:new p(t,n,e,s)};var d=function(t,n){var e=[],r=[];if(!u.isVanillaObject(t))return e.push(new l(t,t,n)),[e,r];for(var o in t)if("$"===o.charAt(0)){var i=y(o,t[o],t,n);null!=i&&e.push(i)}else r.push(O(o.split("."),t[o],t,n));return[e,r]};n.createQueryTester=function(t,e){var r=void 0===e?{}:e,o=r.compare,i=r.operations,s=n.createQueryOperation(t,null,{compare:o||u.equals,operations:Object.assign({},i||{})});return function(t,n,e){return s.reset(),s.next(t,n,e),s.success}}},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.typeChecker=function(t){var n="[object "+t+"]";return function(t){return r(t)===n}};var r=function(t){return Object.prototype.toString.call(t)};n.comparable=function(t){return t instanceof Date?t.getTime():n.isArray(t)?t.map(n.comparable):t&&"function"==typeof t.toJSON?t.toJSON():t},n.isArray=n.typeChecker("Array"),n.isObject=n.typeChecker("Object"),n.isFunction=n.typeChecker("Function"),n.isVanillaObject=function(t){return t&&(t.constructor===Object||t.constructor===Array||"function Object() { [native code] }"===t.constructor.toString()||"function Array() { [native code] }"===t.constructor.toString())&&!t.toJSON},n.equals=function(t,e){if(null==t&&t==e)return!0;if(t===e)return!0;if(Object.prototype.toString.call(t)!==Object.prototype.toString.call(e))return!1;if(n.isArray(t)){if(t.length!==e.length)return!1;for(var r=0,o=t.length;r<o;r++)if(!n.equals(t[r],e[r]))return!1;return!0}if(n.isObject(t)){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var i in t)if(!n.equals(t[i],e[i]))return!1;return!0}return!1}},function(t,n,e){t.exports=e(4)},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e(0),o=e(1);n.createQueryTester=o.createQueryTester,n.EqualsOperation=o.EqualsOperation,n.createEqualsOperation=o.createEqualsOperation;!function(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}(e(0)),n.default=function(t,n){var e=void 0===n?{}:n,i=e.compare,u=e.operations;return o.createQueryTester(t,{compare:i,operations:Object.assign({},r,u)})}}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.sift=e():t.sift=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),u=n(2),c=n(5),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._test=i.createTester(this.params,this.options.compare)},e.prototype.reset=function(){t.prototype.reset.call(this),this.success=!0},e.prototype.next=function(t){this._test(t)&&(this.done=!0,this.success=!1)},e}(i.BaseOperation),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},e.prototype.reset=function(){this._queryOperation.reset()},e.prototype.next=function(t,e,n){this._queryOperation.reset(),c.isArray(n)?(this._queryOperation.next(t,e,n),this.done=this._queryOperation.done||e===n.length-1,this.success=this._queryOperation.success):(this.done=!0,this.success=!1)},e}(i.BaseOperation),f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},e.prototype.reset=function(){this._queryOperation.reset()},e.prototype.next=function(t,e,n){this._queryOperation.next(t,e,n),this.done=this._queryOperation.done,this.success=!this._queryOperation.success},e}(i.BaseOperation),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){var t=this;this._ops=this.params.map((function(e){return i.createQueryOperation(e,null,t.options)}))},e.prototype.reset=function(){this.done=!1,this.success=!1;for(var t=0,e=this._ops.length;t<e;t++)this._ops[t].reset()},e.prototype.next=function(t,e,n){for(var r=!1,o=!1,i=0,u=this._ops.length;i<u;i++){var c=this._ops[i];if(c.next(t,e,n),c.success){r=!0,o=c.success;break}}this.success=o,this.done=r},e}(i.BaseOperation),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(e,n,r){t.prototype.next.call(this,e,n,r),this.success=!this.success},e}(p),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(t,e,n){n.hasOwnProperty(e)===this.params&&(this.done=!0,this.success=!0)},e}(i.BaseOperation),h=function(t){function e(e,n,r){return t.call(this,e,n,r,e.map((function(t){return i.createQueryOperation(t,n,r)})))||this}return o(e,t),e.prototype.next=function(t,e,n){this.childrenNext(t,e,n)},e}(i.GroupOperation);e.$eq=function(t,e,n){return new i.EqualsOperation(t,e,n)},e.$ne=function(t,e,n){return new s(t,e,n)},e.$or=function(t,e,n){return new p(t,e,n)},e.$nor=function(t,e,n){return new l(t,e,n)},e.$elemMatch=function(t,e,n){return new a(t,e,n)},e.$nin=function(t,e,n){return new l(t,e,n)},e.$in=function(t,e,n){return new p(t,e,n)},e.$lt=i.numericalOperation((function(t){return function(e){return e<t}})),e.$lte=i.numericalOperation((function(t){return function(e){return e<=t}})),e.$gt=i.numericalOperation((function(t){return function(e){return e>t}})),e.$gte=i.numericalOperation((function(t){return function(e){return e>=t}})),e.$mod=function(t,e,n){var r=t[0],o=t[1];return new i.EqualsOperation((function(t){return u.comparable(t)%r===o}),e,n)},e.$exists=function(t,e,n){return new y(t,e,n)},e.$regex=function(t,e,n){return new i.EqualsOperation(new RegExp(t,e.$options),e,n)},e.$not=function(t,e,n){return new f(t,e,n)},e.$type=function(t,e,n){return new i.EqualsOperation((function(e){return null!=e&&(e instanceof t||e.constructor===t)}),e,n)},e.$and=function(t,e,n){return new h(t,e,n)},e.$all=e.$and,e.$size=function(t,e,n){return new i.EqualsOperation((function(e){return e&&e.length===t}),e,n)},e.$options=function(){return null},e.$where=function(t,e,n){var r;if(!u.isFunction(t))throw new Error('In CSP mode, sift does not support strings in "$where" condition');return r=t,new i.EqualsOperation((function(t){return r.bind(t)(t)}),e,n)}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),u=function(t,e,n,r,o,c){var s=e[r];if(i.isArray(t)&&isNaN(Number(s)))for(var a=0,f=t.length;a<f;a++)if(!u(t[a],e,n,r,a,t))return!1;return r===e.length||null==t?n(t,o,c):u(t[s],e,n,r+1,s,t)},c=function(){function t(t,e,n){this.params=t,this.owneryQuery=e,this.options=n,this.init()}return t.prototype.init=function(){},t.prototype.reset=function(){this.done=!1,this.success=!1},t}();e.BaseOperation=c;var s=function(t){function e(e,n,r,o){var i=t.call(this,e,n,r)||this;return i._children=o,i}return o(e,t),e.prototype.reset=function(){this.success=!1,this.done=!1;for(var t=0,e=this._children.length;t<e;t++)this._children[t].reset()},e.prototype.childrenNext=function(t,e,n){for(var r=!0,o=!0,i=0,u=this._children.length;i<u;i++){var c=this._children[i];if(c.next(t,e,n),c.success||(o=!1),c.done){if(!c.success)break}else r=!1}this.done=r,this.success=o},e}(c);e.GroupOperation=s;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(t,e,n){this.childrenNext(t,e,n)},e}(s);e.QueryOperation=a;var f=function(t){function e(e,n,r,o,i){var u=t.call(this,n,r,o,i)||this;return u.keyPath=e,u._nextNestedValue=function(t,e,n){return u.childrenNext(t,e,n),!u.done},u}return o(e,t),e.prototype.next=function(t,e,n){u(t,this.keyPath,this._nextNestedValue,0,e,n)},e}(s);e.NestedOperation=f,e.createTester=function(t,e){if(t instanceof Function)return t;if(t instanceof RegExp)return function(e){return"string"==typeof e&&t.test(e)};var n=i.comparable(t);return function(t){return e(n,i.comparable(t))}};var p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._test=e.createTester(this.params,this.options.compare)},n.prototype.next=function(t,e,n){this._test(t,e,n)&&(this.done=!0,this.success=!0)},n}(c);e.EqualsOperation=p,e.createEqualsOperation=function(t,e,n){return new p(t,e,n)};var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(){this.done=!0,this.success=!1},e}(c);e.NopeOperation=l,e.numericalOperationCreator=function(t){return function(e,n,r){return null==e?new l(e,n,r):t(e,n,r)}},e.numericalOperation=function(t){return e.numericalOperationCreator((function(e,n,r){var o=typeof i.comparable(e),u=t(e);return new p((function(t){return typeof i.comparable(t)===o&&u(t)}),n,r)}))};var y=function(t,e,n,r){var o=r.operations[t];if(!o)throw new Error("Unsupported operation: "+t);return o(e,n,r)},h=function(t,e,n,r){if(function(t){for(var e in t)if("$"===e.charAt(0))return!0;return!1}(e)){var o=d(e,r),i=o[0];if(o[1].length)throw new Error("Property queries must contain only operations, or exact objects.");return new f(t,e,n,r,i)}return new f(t,e,n,r,[new p(e,n,r)])};e.createQueryOperation=function(t,e,n){var r=d(t,n),o=r[0],i=r[1],u=[];return o.length&&u.push(new f([],t,e,n,o)),u.push.apply(u,i),1===u.length?u[0]:new a(t,e,n,u)};var d=function(t,e){var n=[],r=[];if(!i.isVanillaObject(t))return n.push(new p(t,t,e)),[n,r];for(var o in t)if("$"===o.charAt(0)){var u=y(o,t[o],t,e);null!=u&&n.push(u)}else r.push(h(o.split("."),t[o],t,e));return[n,r]};e.createQueryTester=function(t,n){var r=void 0===n?{}:n,o=r.compare,u=r.operations,c=e.createQueryOperation(t,null,{compare:o||i.equals,operations:Object.assign({},u||{})});return function(t,e,n){return c.reset(),c.next(t,e,n),c.success}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.typeChecker=function(t){var e="[object "+t+"]";return function(t){return r(t)===e}};var r=function(t){return Object.prototype.toString.call(t)};e.comparable=function(t){return t instanceof Date?t.getTime():e.isArray(t)?t.map(e.comparable):t&&"function"==typeof t.toJSON?t.toJSON():t},e.isArray=e.typeChecker("Array"),e.isObject=e.typeChecker("Object"),e.isFunction=e.typeChecker("Function"),e.isVanillaObject=function(t){return t&&(t.constructor===Object||t.constructor===Array||"function Object() { [native code] }"===t.constructor.toString()||"function Array() { [native code] }"===t.constructor.toString())&&!t.toJSON},e.equals=function(t,n){if(null==t&&t==n)return!0;if(t===n)return!0;if(Object.prototype.toString.call(t)!==Object.prototype.toString.call(n))return!1;if(e.isArray(t)){if(t.length!==n.length)return!1;for(var r=0,o=t.length;r<o;r++)if(!e.equals(t[r],n[r]))return!1;return!0}if(e.isObject(t)){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(var i in t)if(!e.equals(t[i],n[i]))return!1;return!0}return!1}},function(t,e,n){t.exports=n(4)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=n(1);e.createQueryTester=o.createQueryTester,e.EqualsOperation=o.EqualsOperation,e.createEqualsOperation=o.createEqualsOperation;!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0)),e.default=function(t,e){var n=void 0===e?{}:e,i=n.compare,u=n.operations;return o.createQueryTester(t,{compare:i,operations:Object.assign({},r,u)})}},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r<e.length;r++)n[e[r]]=Object.getOwnPropertyDescriptor(t,e[r]);return n},o=/%[sdj%]/g;e.format=function(t){if(!O(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(c(arguments[n]));return e.join(" ")}n=1;for(var r=arguments,i=r.length,u=String(t).replace(o,(function(t){if("%%"===t)return"%";if(n>=i)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n<i;s=r[++n])d(s)||!v(s)?u+=" "+s:u+=" "+c(s);return u},e.deprecate=function(n,r){if(void 0!==t&&!0===t.noDeprecation)return n;if(void 0===t)return function(){return e.deprecate(n,r).apply(this,arguments)};var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(r);t.traceDeprecation?console.trace(r):console.error(r),o=!0}return n.apply(this,arguments)}};var i,u={};function c(t,n){var r={seen:[],stylize:a};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),h(n)?r.showHidden=n:n&&e._extend(r,n),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=c.styles[e];return n?"["+c.colors[n][0]+"m"+t+"["+c.colors[n][1]+"m":t}function a(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&_(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,t);return O(o)||(o=f(t,o,r)),o}var i=function(t,e){if(b(e))return t.stylize("undefined","undefined");if(O(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(g(e))return t.stylize(""+e,"number");if(h(e))return t.stylize(""+e,"boolean");if(d(e))return t.stylize("null","null")}(t,n);if(i)return i;var u=Object.keys(n),c=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),j(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return p(n);if(0===u.length){if(_(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(m(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return t.stylize(Date.prototype.toString.call(n),"date");if(j(n))return p(n)}var a,v="",x=!1,E=["{","}"];(y(n)&&(x=!0,E=["[","]"]),_(n))&&(v=" [Function"+(n.name?": "+n.name:"")+"]");return m(n)&&(v=" "+RegExp.prototype.toString.call(n)),w(n)&&(v=" "+Date.prototype.toUTCString.call(n)),j(n)&&(v=" "+p(n)),0!==u.length||x&&0!=n.length?r<0?m(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),a=x?function(t,e,n,r,o){for(var i=[],u=0,c=e.length;u<c;++u)P(e,String(u))?i.push(l(t,e,n,r,String(u),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(l(t,e,n,r,o,!0))})),i}(t,n,r,c,u):u.map((function(e){return l(t,n,r,c,e,x)})),t.seen.pop(),function(t,e,n){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(a,v,E)):E[0]+v+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,o,i){var u,c,s;if((s=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?c=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(c=t.stylize("[Setter]","special")),P(r,o)||(u="["+o+"]"),c||(t.seen.indexOf(s.value)<0?(c=d(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+c.split("\n").map((function(t){return" "+t})).join("\n")):c=t.stylize("[Circular]","special")),b(u)){if(i&&o.match(/^\d+$/))return c;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+c}function y(t){return Array.isArray(t)}function h(t){return"boolean"==typeof t}function d(t){return null===t}function g(t){return"number"==typeof t}function O(t){return"string"==typeof t}function b(t){return void 0===t}function m(t){return v(t)&&"[object RegExp]"===x(t)}function v(t){return"object"==typeof t&&null!==t}function w(t){return v(t)&&"[object Date]"===x(t)}function j(t){return v(t)&&("[object Error]"===x(t)||t instanceof Error)}function _(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function E(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(b(i)&&(i=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(i)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=y,e.isBoolean=h,e.isNull=d,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=O,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=b,e.isRegExp=m,e.isObject=v,e.isDate=w,e.isError=j,e.isFunction=_,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(7);var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(){var t=new Date,e=[E(t.getHours()),E(t.getMinutes()),E(t.getSeconds())].join(":");return[t.getDate(),S[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",T(),e.format.apply(e,arguments))},e.inherits=n(8),e._extend=function(t,e){if(!e||!v(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var $="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function q(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if($&&t[$]){var e;if("function"!=typeof(e=t[$]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,$,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),o=[],i=0;i<arguments.length;i++)o.push(arguments[i]);o.push((function(t,r){t?n(t):e(r)}));try{t.apply(this,o)}catch(t){n(t)}return r}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),$&&Object.defineProperty(e,$,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,r(t))},e.promisify.custom=$,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var i=this,u=function(){return o.apply(i,arguments)};e.apply(this,n).then((function(e){t.nextTick(u,null,e)}),(function(e){t.nextTick(q,e,u)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,r(e)),n}}).call(this,n(6))},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,a=[],f=!1,p=-1;function l(){f&&s&&(f=!1,s.length?a=s.concat(a):p=-1,a.length&&y())}function y(){if(!f){var t=c(l);f=!0;for(var e=a.length;e;){for(s=a,a=[];++p<e;)s&&s[p].run();p=-1,e=a.length}s=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function h(t,e){this.fun=t,this.array=e}function d(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];a.push(new h(t,e)),1!==a.length||f||c(y)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=d,o.addListener=d,o.once=d,o.off=d,o.removeListener=d,o.removeAllListeners=d,o.emit=d,o.prependListener=d,o.prependOnceListener=d,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}])})); | ||
//# sourceMappingURL=sift.csp.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sift=n():t.sift=n()}(this,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=3)}([function(t,n,e){"use strict";var r,o=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(n,"__esModule",{value:!0});var i=e(1),u=e(2),s=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._test=i.createTester(this.params,this.options.compare)},n.prototype.reset=function(){t.prototype.reset.call(this),this.success=!0},n.prototype.next=function(t){this._test(t)&&(this.done=!0,this.success=!1)},n}(i.BaseOperation),c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},n.prototype.reset=function(){this._queryOperation.reset()},n.prototype.next=function(t,n,e){this._queryOperation.next(t,n,e),this.done=this._queryOperation.done,this.success=this._queryOperation.success},n}(i.BaseOperation),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(n,e,r){t.prototype.next.call(this,n,e,r),this.success=!this.success},n}(c),p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){var t=this;this._ops=this.params.map((function(n){return i.createQueryOperation(n,null,t.options)}))},n.prototype.reset=function(){this.done=!1,this.success=!1;for(var t=0,n=this._ops.length;t<n;t++)this._ops[t].reset()},n.prototype.next=function(t,n,e){for(var r=!1,o=!1,i=0,u=this._ops.length;i<u;i++){var s=this._ops[i];if(s.next(t,n,e),s.success){r=!0,o=s.success;break}}this.success=o,this.done=r},n}(i.BaseOperation),f=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(n,e,r){t.prototype.next.call(this,n,e,r),this.success=!this.success},n}(p),l=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(t,n,e){e.hasOwnProperty(n)===this.params&&(this.done=!0,this.success=!0)},n}(i.BaseOperation),h=function(t){function n(n,e,r){return t.call(this,n,e,r,n.map((function(t){return i.createQueryOperation(t,e,r)})))||this}return o(n,t),n.prototype.next=function(t,n,e){this.childrenNext(t,n,e)},n}(i.GroupOperation);n.$eq=function(t,n,e){return new i.EqualsOperation(t,n,e)},n.$ne=function(t,n,e){return new s(t,n,e)},n.$or=function(t,n,e){return new p(t,n,e)},n.$nor=function(t,n,e){return new f(t,n,e)},n.$elemMatch=function(t,n,e){return new c(t,n,e)},n.$nin=function(t,n,e){return new f(t,n,e)},n.$in=function(t,n,e){return new p(t,n,e)},n.$lt=i.numericalOperation((function(t){return function(n){return n<t}})),n.$lte=i.numericalOperation((function(t){return function(n){return n<=t}})),n.$gt=i.numericalOperation((function(t){return function(n){return n>t}})),n.$gte=i.numericalOperation((function(t){return function(n){return n>=t}})),n.$mod=function(t,n,e){var r=t[0],o=t[1];return new i.EqualsOperation((function(t){return u.comparable(t)%r===o}),n,e)},n.$exists=function(t,n,e){return new l(t,n,e)},n.$regex=function(t,n,e){return new i.EqualsOperation(new RegExp(t,n.$options),n,e)},n.$not=function(t,n,e){return new a(t,n,e)},n.$type=function(t,n,e){return new i.EqualsOperation((function(n){return null!=n&&(n instanceof t||n.constructor===t)}),n,e)},n.$and=function(t,n,e){return new h(t,n,e)},n.$all=n.$and,n.$size=function(t,n,e){return new i.EqualsOperation((function(n){return n&&n.length===t}),n,e)},n.$options=function(){return null},n.$where=function(t,n,e){var r;return r=u.isFunction(t)?t:new Function("obj","return "+t),new i.EqualsOperation((function(t){return r.bind(t)(t)}),n,e)}},function(t,n,e){"use strict";var r,o=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),i=this&&this.__spreadArrays||function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var r=Array(t),o=0;for(n=0;n<e;n++)for(var i=arguments[n],u=0,s=i.length;u<s;u++,o++)r[o]=i[u];return r};Object.defineProperty(n,"__esModule",{value:!0});var u=e(2),s=function(t,n,e,r,o,i){var c=n[r];if(u.isArray(t)&&isNaN(Number(c)))for(var a=0,p=t.length;a<p;a++)if(!s(t[a],n,e,r,a,t))return!1;return r===n.length||null==t?e(t,o,i):s(t[c],n,e,r+1,c,t)},c=function(){function t(t,n,e){this.params=t,this.owneryQuery=n,this.options=e,this.init()}return t.prototype.init=function(){},t.prototype.reset=function(){this.done=!1,this.success=!1},t}();n.BaseOperation=c;var a=function(t){function n(n,e,r,o){var i=t.call(this,n,e,r)||this;return i._children=o,i}return o(n,t),n.prototype.reset=function(){this.success=!1,this.done=!1;for(var t=0,n=this._children.length;t<n;t++)this._children[t].reset()},n.prototype.childrenNext=function(t,n,e){for(var r=!0,o=!0,i=0,u=this._children.length;i<u;i++){var s=this._children[i];if(s.next(t,n,e),s.success||(o=!1),s.done){if(!s.success)break}else r=!1}this.done=r,this.success=o},n}(c);n.GroupOperation=a;var p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(t,n,e){this.childrenNext(t,n,e)},n}(a);n.QueryOperation=p;var f=function(t){function n(n,e,r,o,i){var u=t.call(this,e,r,o,i)||this;return u.keyPath=n,u._nextNestedValue=function(t,n,e){return u.childrenNext(t,n,e),!u.done},u}return o(n,t),n.prototype.next=function(t,n,e){s(t,this.keyPath,this._nextNestedValue,0,n,e)},n}(a);n.NestedOperation=f,n.createTester=function(t,n){if(t instanceof Function)return t;if(t instanceof RegExp)return function(n){return"string"==typeof n&&t.test(n)};var e=u.comparable(t);return function(t){return n(e,u.comparable(t))}};var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._test=n.createTester(this.params,this.options.compare)},e.prototype.next=function(t,n,e){this._test(t,n,e)&&(this.done=!0,this.success=!0)},e}(c);n.EqualsOperation=l,n.createEqualsOperation=function(t,n,e){return new l(t,n,e)};var h=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.next=function(){this.done=!0,this.success=!1},n}(c);n.NopeOperation=h,n.numericalOperationCreator=function(t){return function(n,e,r){return null==n?new h(n,e,r):t(n,e,r)}},n.numericalOperation=function(t){return n.numericalOperationCreator((function(n,e,r){var o=typeof u.comparable(n),i=t(n);return new l((function(t){return typeof u.comparable(t)===o&&i(t)}),e,r)}))};var y=function(t,n,e,r){var o=r.operations[t];if(!o)throw new Error("Unsupported operation: "+t);return o(n,e,r)},O=function(t,n,e,r){if(function(t){for(var n in t)if("$"===n.charAt(0))return!0;return!1}(n)){var o=d(n,r),i=o[0];if(o[1].length)throw new Error("Property queries must contain only operations, or exact objects.");return new f(t,n,e,r,i)}return new f(t,n,e,r,[new l(n,e,r)])};n.createQueryOperation=function(t,n,e){var r=d(t,e),o=r[0],u=r[1],s=i([new f([],t,n,e,o)],u);return 1===s.length?s[0]:new p(t,n,e,s)};var d=function(t,n){var e=[],r=[];if(!u.isVanillaObject(t))return e.push(new l(t,t,n)),[e,r];for(var o in t)if("$"===o.charAt(0)){var i=y(o,t[o],t,n);null!=i&&e.push(i)}else r.push(O(o.split("."),t[o],t,n));return[e,r]};n.createQueryTester=function(t,e){var r=void 0===e?{}:e,o=r.compare,i=r.operations,s=n.createQueryOperation(t,null,{compare:o||u.equals,operations:Object.assign({},i||{})});return function(t,n,e){return s.reset(),s.next(t,n,e),s.success}}},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.typeChecker=function(t){var n="[object "+t+"]";return function(t){return r(t)===n}};var r=function(t){return Object.prototype.toString.call(t)};n.comparable=function(t){return t instanceof Date?t.getTime():n.isArray(t)?t.map(n.comparable):t&&"function"==typeof t.toJSON?t.toJSON():t},n.isArray=n.typeChecker("Array"),n.isObject=n.typeChecker("Object"),n.isFunction=n.typeChecker("Function"),n.isVanillaObject=function(t){return t&&(t.constructor===Object||t.constructor===Array||"function Object() { [native code] }"===t.constructor.toString()||"function Array() { [native code] }"===t.constructor.toString())&&!t.toJSON},n.equals=function(t,e){if(null==t&&t==e)return!0;if(t===e)return!0;if(Object.prototype.toString.call(t)!==Object.prototype.toString.call(e))return!1;if(n.isArray(t)){if(t.length!==e.length)return!1;for(var r=0,o=t.length;r<o;r++)if(!n.equals(t[r],e[r]))return!1;return!0}if(n.isObject(t)){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var i in t)if(!n.equals(t[i],e[i]))return!1;return!0}return!1}},function(t,n,e){t.exports=e(4)},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e(0),o=e(1);n.createQueryTester=o.createQueryTester,n.EqualsOperation=o.EqualsOperation,n.createEqualsOperation=o.createEqualsOperation;!function(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}(e(0)),n.default=function(t,n){var e=void 0===n?{}:n,i=e.compare,u=e.operations;return o.createQueryTester(t,{compare:i,operations:Object.assign({},r,u)})}}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.sift=e():t.sift=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),u=n(2),c=n(5),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._test=i.createTester(this.params,this.options.compare)},e.prototype.reset=function(){t.prototype.reset.call(this),this.success=!0},e.prototype.next=function(t){this._test(t)&&(this.done=!0,this.success=!1)},e}(i.BaseOperation),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},e.prototype.reset=function(){this._queryOperation.reset()},e.prototype.next=function(t,e,n){this._queryOperation.reset(),c.isArray(n)?(this._queryOperation.next(t,e,n),this.done=this._queryOperation.done||e===n.length-1,this.success=this._queryOperation.success):(this.done=!0,this.success=!1)},e}(i.BaseOperation),f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){this._queryOperation=i.createQueryOperation(this.params,this.owneryQuery,this.options)},e.prototype.reset=function(){this._queryOperation.reset()},e.prototype.next=function(t,e,n){this._queryOperation.next(t,e,n),this.done=this._queryOperation.done,this.success=!this._queryOperation.success},e}(i.BaseOperation),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.init=function(){var t=this;this._ops=this.params.map((function(e){return i.createQueryOperation(e,null,t.options)}))},e.prototype.reset=function(){this.done=!1,this.success=!1;for(var t=0,e=this._ops.length;t<e;t++)this._ops[t].reset()},e.prototype.next=function(t,e,n){for(var r=!1,o=!1,i=0,u=this._ops.length;i<u;i++){var c=this._ops[i];if(c.next(t,e,n),c.success){r=!0,o=c.success;break}}this.success=o,this.done=r},e}(i.BaseOperation),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(e,n,r){t.prototype.next.call(this,e,n,r),this.success=!this.success},e}(p),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(t,e,n){n.hasOwnProperty(e)===this.params&&(this.done=!0,this.success=!0)},e}(i.BaseOperation),h=function(t){function e(e,n,r){return t.call(this,e,n,r,e.map((function(t){return i.createQueryOperation(t,n,r)})))||this}return o(e,t),e.prototype.next=function(t,e,n){this.childrenNext(t,e,n)},e}(i.GroupOperation);e.$eq=function(t,e,n){return new i.EqualsOperation(t,e,n)},e.$ne=function(t,e,n){return new s(t,e,n)},e.$or=function(t,e,n){return new p(t,e,n)},e.$nor=function(t,e,n){return new l(t,e,n)},e.$elemMatch=function(t,e,n){return new a(t,e,n)},e.$nin=function(t,e,n){return new l(t,e,n)},e.$in=function(t,e,n){return new p(t,e,n)},e.$lt=i.numericalOperation((function(t){return function(e){return e<t}})),e.$lte=i.numericalOperation((function(t){return function(e){return e<=t}})),e.$gt=i.numericalOperation((function(t){return function(e){return e>t}})),e.$gte=i.numericalOperation((function(t){return function(e){return e>=t}})),e.$mod=function(t,e,n){var r=t[0],o=t[1];return new i.EqualsOperation((function(t){return u.comparable(t)%r===o}),e,n)},e.$exists=function(t,e,n){return new y(t,e,n)},e.$regex=function(t,e,n){return new i.EqualsOperation(new RegExp(t,e.$options),e,n)},e.$not=function(t,e,n){return new f(t,e,n)},e.$type=function(t,e,n){return new i.EqualsOperation((function(e){return null!=e&&(e instanceof t||e.constructor===t)}),e,n)},e.$and=function(t,e,n){return new h(t,e,n)},e.$all=e.$and,e.$size=function(t,e,n){return new i.EqualsOperation((function(e){return e&&e.length===t}),e,n)},e.$options=function(){return null},e.$where=function(t,e,n){var r;return r=u.isFunction(t)?t:new Function("obj","return "+t),new i.EqualsOperation((function(t){return r.bind(t)(t)}),e,n)}},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),u=function(t,e,n,r,o,c){var s=e[r];if(i.isArray(t)&&isNaN(Number(s)))for(var a=0,f=t.length;a<f;a++)if(!u(t[a],e,n,r,a,t))return!1;return r===e.length||null==t?n(t,o,c):u(t[s],e,n,r+1,s,t)},c=function(){function t(t,e,n){this.params=t,this.owneryQuery=e,this.options=n,this.init()}return t.prototype.init=function(){},t.prototype.reset=function(){this.done=!1,this.success=!1},t}();e.BaseOperation=c;var s=function(t){function e(e,n,r,o){var i=t.call(this,e,n,r)||this;return i._children=o,i}return o(e,t),e.prototype.reset=function(){this.success=!1,this.done=!1;for(var t=0,e=this._children.length;t<e;t++)this._children[t].reset()},e.prototype.childrenNext=function(t,e,n){for(var r=!0,o=!0,i=0,u=this._children.length;i<u;i++){var c=this._children[i];if(c.next(t,e,n),c.success||(o=!1),c.done){if(!c.success)break}else r=!1}this.done=r,this.success=o},e}(c);e.GroupOperation=s;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(t,e,n){this.childrenNext(t,e,n)},e}(s);e.QueryOperation=a;var f=function(t){function e(e,n,r,o,i){var u=t.call(this,n,r,o,i)||this;return u.keyPath=e,u._nextNestedValue=function(t,e,n){return u.childrenNext(t,e,n),!u.done},u}return o(e,t),e.prototype.next=function(t,e,n){u(t,this.keyPath,this._nextNestedValue,0,e,n)},e}(s);e.NestedOperation=f,e.createTester=function(t,e){if(t instanceof Function)return t;if(t instanceof RegExp)return function(e){return"string"==typeof e&&t.test(e)};var n=i.comparable(t);return function(t){return e(n,i.comparable(t))}};var p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.init=function(){this._test=e.createTester(this.params,this.options.compare)},n.prototype.next=function(t,e,n){this._test(t,e,n)&&(this.done=!0,this.success=!0)},n}(c);e.EqualsOperation=p,e.createEqualsOperation=function(t,e,n){return new p(t,e,n)};var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.next=function(){this.done=!0,this.success=!1},e}(c);e.NopeOperation=l,e.numericalOperationCreator=function(t){return function(e,n,r){return null==e?new l(e,n,r):t(e,n,r)}},e.numericalOperation=function(t){return e.numericalOperationCreator((function(e,n,r){var o=typeof i.comparable(e),u=t(e);return new p((function(t){return typeof i.comparable(t)===o&&u(t)}),n,r)}))};var y=function(t,e,n,r){var o=r.operations[t];if(!o)throw new Error("Unsupported operation: "+t);return o(e,n,r)},h=function(t,e,n,r){if(function(t){for(var e in t)if("$"===e.charAt(0))return!0;return!1}(e)){var o=d(e,r),i=o[0];if(o[1].length)throw new Error("Property queries must contain only operations, or exact objects.");return new f(t,e,n,r,i)}return new f(t,e,n,r,[new p(e,n,r)])};e.createQueryOperation=function(t,e,n){var r=d(t,n),o=r[0],i=r[1],u=[];return o.length&&u.push(new f([],t,e,n,o)),u.push.apply(u,i),1===u.length?u[0]:new a(t,e,n,u)};var d=function(t,e){var n=[],r=[];if(!i.isVanillaObject(t))return n.push(new p(t,t,e)),[n,r];for(var o in t)if("$"===o.charAt(0)){var u=y(o,t[o],t,e);null!=u&&n.push(u)}else r.push(h(o.split("."),t[o],t,e));return[n,r]};e.createQueryTester=function(t,n){var r=void 0===n?{}:n,o=r.compare,u=r.operations,c=e.createQueryOperation(t,null,{compare:o||i.equals,operations:Object.assign({},u||{})});return function(t,e,n){return c.reset(),c.next(t,e,n),c.success}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.typeChecker=function(t){var e="[object "+t+"]";return function(t){return r(t)===e}};var r=function(t){return Object.prototype.toString.call(t)};e.comparable=function(t){return t instanceof Date?t.getTime():e.isArray(t)?t.map(e.comparable):t&&"function"==typeof t.toJSON?t.toJSON():t},e.isArray=e.typeChecker("Array"),e.isObject=e.typeChecker("Object"),e.isFunction=e.typeChecker("Function"),e.isVanillaObject=function(t){return t&&(t.constructor===Object||t.constructor===Array||"function Object() { [native code] }"===t.constructor.toString()||"function Array() { [native code] }"===t.constructor.toString())&&!t.toJSON},e.equals=function(t,n){if(null==t&&t==n)return!0;if(t===n)return!0;if(Object.prototype.toString.call(t)!==Object.prototype.toString.call(n))return!1;if(e.isArray(t)){if(t.length!==n.length)return!1;for(var r=0,o=t.length;r<o;r++)if(!e.equals(t[r],n[r]))return!1;return!0}if(e.isObject(t)){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(var i in t)if(!e.equals(t[i],n[i]))return!1;return!0}return!1}},function(t,e,n){t.exports=n(4)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=n(1);e.createQueryTester=o.createQueryTester,e.EqualsOperation=o.EqualsOperation,e.createEqualsOperation=o.createEqualsOperation;!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0)),e.default=function(t,e){var n=void 0===e?{}:e,i=n.compare,u=n.operations;return o.createQueryTester(t,{compare:i,operations:Object.assign({},r,u)})}},function(t,e,n){(function(t){var r=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r<e.length;r++)n[e[r]]=Object.getOwnPropertyDescriptor(t,e[r]);return n},o=/%[sdj%]/g;e.format=function(t){if(!O(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(c(arguments[n]));return e.join(" ")}n=1;for(var r=arguments,i=r.length,u=String(t).replace(o,(function(t){if("%%"===t)return"%";if(n>=i)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}})),s=r[n];n<i;s=r[++n])d(s)||!v(s)?u+=" "+s:u+=" "+c(s);return u},e.deprecate=function(n,r){if(void 0!==t&&!0===t.noDeprecation)return n;if(void 0===t)return function(){return e.deprecate(n,r).apply(this,arguments)};var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(r);t.traceDeprecation?console.trace(r):console.error(r),o=!0}return n.apply(this,arguments)}};var i,u={};function c(t,n){var r={seen:[],stylize:a};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),h(n)?r.showHidden=n:n&&e._extend(r,n),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,t,r.depth)}function s(t,e){var n=c.styles[e];return n?"["+c.colors[n][0]+"m"+t+"["+c.colors[n][1]+"m":t}function a(t,e){return t}function f(t,n,r){if(t.customInspect&&n&&_(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,t);return O(o)||(o=f(t,o,r)),o}var i=function(t,e){if(b(e))return t.stylize("undefined","undefined");if(O(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(g(e))return t.stylize(""+e,"number");if(h(e))return t.stylize(""+e,"boolean");if(d(e))return t.stylize("null","null")}(t,n);if(i)return i;var u=Object.keys(n),c=function(t){var e={};return t.forEach((function(t,n){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(n)),j(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return p(n);if(0===u.length){if(_(n)){var s=n.name?": "+n.name:"";return t.stylize("[Function"+s+"]","special")}if(m(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return t.stylize(Date.prototype.toString.call(n),"date");if(j(n))return p(n)}var a,v="",x=!1,E=["{","}"];(y(n)&&(x=!0,E=["[","]"]),_(n))&&(v=" [Function"+(n.name?": "+n.name:"")+"]");return m(n)&&(v=" "+RegExp.prototype.toString.call(n)),w(n)&&(v=" "+Date.prototype.toUTCString.call(n)),j(n)&&(v=" "+p(n)),0!==u.length||x&&0!=n.length?r<0?m(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special"):(t.seen.push(n),a=x?function(t,e,n,r,o){for(var i=[],u=0,c=e.length;u<c;++u)P(e,String(u))?i.push(l(t,e,n,r,String(u),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(l(t,e,n,r,o,!0))})),i}(t,n,r,c,u):u.map((function(e){return l(t,n,r,c,e,x)})),t.seen.pop(),function(t,e,n){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(a,v,E)):E[0]+v+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,o,i){var u,c,s;if((s=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?c=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(c=t.stylize("[Setter]","special")),P(r,o)||(u="["+o+"]"),c||(t.seen.indexOf(s.value)<0?(c=d(n)?f(t,s.value,null):f(t,s.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+c.split("\n").map((function(t){return" "+t})).join("\n")):c=t.stylize("[Circular]","special")),b(u)){if(i&&o.match(/^\d+$/))return c;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+c}function y(t){return Array.isArray(t)}function h(t){return"boolean"==typeof t}function d(t){return null===t}function g(t){return"number"==typeof t}function O(t){return"string"==typeof t}function b(t){return void 0===t}function m(t){return v(t)&&"[object RegExp]"===x(t)}function v(t){return"object"==typeof t&&null!==t}function w(t){return v(t)&&"[object Date]"===x(t)}function j(t){return v(t)&&("[object Error]"===x(t)||t instanceof Error)}function _(t){return"function"==typeof t}function x(t){return Object.prototype.toString.call(t)}function E(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(n){if(b(i)&&(i=t.env.NODE_DEBUG||""),n=n.toUpperCase(),!u[n])if(new RegExp("\\b"+n+"\\b","i").test(i)){var r=t.pid;u[n]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",n,r,t)}}else u[n]=function(){};return u[n]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=y,e.isBoolean=h,e.isNull=d,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=O,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=b,e.isRegExp=m,e.isObject=v,e.isDate=w,e.isError=j,e.isFunction=_,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=n(7);var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function S(){var t=new Date,e=[E(t.getHours()),E(t.getMinutes()),E(t.getSeconds())].join(":");return[t.getDate(),T[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",S(),e.format.apply(e,arguments))},e.inherits=n(8),e._extend=function(t,e){if(!e||!v(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t};var $="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function q(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if($&&t[$]){var e;if("function"!=typeof(e=t[$]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,$,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,n,r=new Promise((function(t,r){e=t,n=r})),o=[],i=0;i<arguments.length;i++)o.push(arguments[i]);o.push((function(t,r){t?n(t):e(r)}));try{t.apply(this,o)}catch(t){n(t)}return r}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),$&&Object.defineProperty(e,$,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,r(t))},e.promisify.custom=$,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var i=this,u=function(){return o.apply(i,arguments)};e.apply(this,n).then((function(e){t.nextTick(u,null,e)}),(function(e){t.nextTick(q,e,u)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,r(e)),n}}).call(this,n(6))},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var s,a=[],f=!1,p=-1;function l(){f&&s&&(f=!1,s.length?a=s.concat(a):p=-1,a.length&&y())}function y(){if(!f){var t=c(l);f=!0;for(var e=a.length;e;){for(s=a,a=[];++p<e;)s&&s[p].run();p=-1,e=a.length}s=null,f=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function h(t,e){this.fun=t,this.array=e}function d(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];a.push(new h(t,e)),1!==a.length||f||c(y)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=d,o.addListener=d,o.once=d,o.off=d,o.removeListener=d,o.removeAllListeners=d,o.emit=d,o.prependListener=d,o.prependOnceListener=d,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}])})); | ||
//# sourceMappingURL=sift.min.js.map |
@@ -110,3 +110,3 @@ import { | ||
options: Options, | ||
private readonly _children: Operation[] | ||
protected readonly _children: Operation[] | ||
) { | ||
@@ -149,2 +149,3 @@ super(params, owneryQuery, options); | ||
} | ||
// console.log("DONE", this.params, done, success); | ||
this.done = done; | ||
@@ -324,11 +325,15 @@ this.success = success; | ||
const ops = [ | ||
new NestedOperation([], query, owneryQuery, options, selfOperations), | ||
...nestedOperations | ||
]; | ||
const ops = []; | ||
if (selfOperations.length) { | ||
ops.push( | ||
new NestedOperation([], query, owneryQuery, options, selfOperations) | ||
); | ||
} | ||
ops.push(...nestedOperations); | ||
if (ops.length === 1) { | ||
return ops[0]; | ||
} | ||
return new QueryOperation(query, owneryQuery, options, ops); | ||
@@ -335,0 +340,0 @@ }; |
@@ -16,2 +16,3 @@ import { | ||
import { Key, comparable, isFunction } from "./utils"; | ||
import { isArray } from "util"; | ||
@@ -35,4 +36,6 @@ class $Ne extends BaseOperation<any> { | ||
// https://docs.mongodb.com/manual/reference/operator/query/elemMatch/ | ||
class $ElemMatch extends BaseOperation<Query> { | ||
private _queryOperation: QueryOperation; | ||
private _current: any; | ||
init() { | ||
@@ -48,13 +51,31 @@ this._queryOperation = createQueryOperation( | ||
} | ||
next(item: any, key: Key, owner: any) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = this._queryOperation.success; | ||
next(item: any, key: Key, owner: any[]) { | ||
this._queryOperation.reset(); | ||
if (isArray(owner)) { | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done || key === owner.length - 1; | ||
this.success = this._queryOperation.success; | ||
} else { | ||
this.done = true; | ||
this.success = false; | ||
} | ||
} | ||
} | ||
class $Not extends $ElemMatch { | ||
class $Not extends BaseOperation<Query> { | ||
private _queryOperation: QueryOperation; | ||
init() { | ||
this._queryOperation = createQueryOperation( | ||
this.params, | ||
this.owneryQuery, | ||
this.options | ||
); | ||
} | ||
reset() { | ||
this._queryOperation.reset(); | ||
} | ||
next(item: any, key: Key, owner: any) { | ||
super.next(item, key, owner); | ||
this.success = !this.success; | ||
this._queryOperation.next(item, key, owner); | ||
this.done = this._queryOperation.done; | ||
this.success = !this._queryOperation.success; | ||
} | ||
@@ -61,0 +82,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import * as assert from "assert"; | ||
import sift from ".."; | ||
const assert = require("assert"); | ||
const sift = require(".."); | ||
@@ -4,0 +4,0 @@ describe(__filename + "#", () => { |
@@ -1,5 +0,5 @@ | ||
import * as assert from "assert"; | ||
import { default as _eval } from "eval"; | ||
import sift, { indexOf as siftIndexOf } from ".."; | ||
import { ObjectID } from "bson"; | ||
const assert = require("assert"); | ||
const _eval = require("eval"); | ||
const { default: sift } = require(".."); | ||
const { ObjectID } = require("bson"); | ||
@@ -6,0 +6,0 @@ describe(__filename + "#", function() { |
@@ -1,3 +0,3 @@ | ||
import * as assert from "assert"; | ||
import sift from ".."; | ||
const assert = require("assert"); | ||
const sift = require(".."); | ||
@@ -4,0 +4,0 @@ describe(__filename + "#", () => { |
@@ -1,18 +0,13 @@ | ||
import * as assert from "assert"; | ||
import * as Immutable from "immutable"; | ||
// describe(__filename + "#", function() { | ||
// var topic = Immutable.List([1, 2, 3, 4, 5, 6, 6, 4, 3]); | ||
import sift from ".."; | ||
// var persons = Immutable.fromJS([ | ||
// { person: { age: 3 } }, | ||
// { person: { age: 5 } }, | ||
// { person: { age: 8 } } | ||
// ]); | ||
describe(__filename + "#", function() { | ||
var topic = Immutable.List([1, 2, 3, 4, 5, 6, 6, 4, 3]); | ||
var persons = Immutable.fromJS([ | ||
{ person: { age: 3 } }, | ||
{ person: { age: 5 } }, | ||
{ person: { age: 8 } } | ||
]); | ||
xit("works with Immutable.Map in a Immutable.List", function() { | ||
assert.equal(persons.filter(sift({ "person.age": { $gt: 4 } })).size, 2); | ||
}); | ||
}); | ||
// xit("works with Immutable.Map in a Immutable.List", function() { | ||
// assert.equal(persons.filter(sift({ "person.age": { $gt: 4 } })).size, 2); | ||
// }); | ||
// }); |
@@ -1,3 +0,3 @@ | ||
import assert from "assert"; | ||
import sift from ".."; | ||
const assert = require("assert"); | ||
const sift = require(".."); | ||
@@ -4,0 +4,0 @@ describe(__filename + "#", function() { |
@@ -1,11 +0,13 @@ | ||
import * as assert from "assert"; | ||
import sift from ".."; | ||
const assert = require("assert"); | ||
const sift = require(".."); | ||
var ObjectID = require("bson").ObjectID; | ||
const MongoClient = require("mongodb").MongoClient; | ||
const { promisify } = require("util"); | ||
describe(__filename + "#", function() { | ||
[ | ||
[{ $lt: new Date() }, [null], []], | ||
[{ $lt: new Date() }, [null], [], false], | ||
// $eq | ||
[{ $eq: 5 }, [5, "5", 6], [5]], | ||
[{ $eq: 5 }, [5, "5", 6], [5], false], | ||
[ | ||
@@ -16,17 +18,18 @@ { a: { $eq: { b: 1 } } }, | ||
], | ||
["5", [5, "5", 6], ["5"]], | ||
[false, [false, "false", true], [false]], | ||
[true, [1, true], [true]], | ||
[0, [0, "0"], [0]], | ||
[null, [null], [null]], | ||
[undefined, [undefined, null], [undefined, null]], | ||
["5", [5, "5", 6], ["5"], false], | ||
[false, [false, "false", true], [false], false], | ||
[true, [1, true], [true], false], | ||
[0, [0, "0"], [0], false], | ||
[null, [null], [null], false], | ||
[undefined, [undefined, null], [undefined, null], false], | ||
[{ aaaaa: { $nin: [null] } }, [{ root: { defined: 1337 } }], []], | ||
[1, [2, 3, 4, 5], []], | ||
[1, [[1]], [[1]]], | ||
[1, [2, 3, 4, 5], [], false], | ||
[1, [[1]], [[1]], false], | ||
[ | ||
new Date(1), | ||
[new Date(), new Date(1), new Date(2), new Date(3)], | ||
[new Date(1)] | ||
[new Date(1)], | ||
false | ||
], | ||
[/^a/, ["a", "ab", "abc", "b", "bc"], ["a", "ab", "abc"]], | ||
[/^a/, ["a", "ab", "abc", "b", "bc"], ["a", "ab", "abc"], false], | ||
@@ -38,3 +41,4 @@ [ | ||
[1, 2, 3], | ||
[1] | ||
[1], | ||
false | ||
], | ||
@@ -45,3 +49,4 @@ | ||
[new ObjectID(), new ObjectID("54dd5546b1d296a54d152e84")], | ||
[new ObjectID("54dd5546b1d296a54d152e84")] | ||
[new ObjectID("54dd5546b1d296a54d152e84")], | ||
false | ||
], | ||
@@ -118,8 +123,8 @@ | ||
// $ne | ||
[{ $ne: 5 }, [5, "5", 6], ["5", 6]], | ||
[{ $ne: "5" }, ["5", 6], [6]], | ||
[{ $ne: false }, [false], []], | ||
[{ $ne: undefined }, [false, 0, "0", undefined], [false, 0, "0"]], | ||
[{ $ne: /^a/ }, ["a", "ab", "abc", "b", "bc"], ["b", "bc"]], | ||
[{ $ne: 1 }, [[2], [1]], [[2]]], | ||
[{ $ne: 5 }, [5, "5", 6], ["5", 6], false], | ||
[{ $ne: "5" }, ["5", 6], [6], false], | ||
[{ $ne: false }, [false], [], false], | ||
[{ $ne: undefined }, [false, 0, "0", undefined], [false, 0, "0"], false], | ||
[{ $ne: /^a/ }, ["a", "ab", "abc", "b", "bc"], ["b", "bc"], false], | ||
[{ $ne: 1 }, [[2], [1]], [[2]], false], | ||
[ | ||
@@ -132,29 +137,36 @@ { groups: { $ne: 111 } }, | ||
// $lt | ||
[{ $lt: 5 }, [3, 4, 5, 6], [3, 4]], | ||
[{ $lt: "c" }, ["a", "b", "c"], ["a", "b"]], | ||
[{ $lt: "5" }, [4, 3, 2, 1], []], | ||
[{ $lt: null }, [-3, -4], []], | ||
[{ $lt: new Date() }, [null], []], | ||
[{ $lt: new Date() }, [new Date("2010-01-01")], [new Date("2010-01-01")]], | ||
[{ $lt: 5 }, [3, 4, 5, 6], [3, 4], false], | ||
[{ $lt: "c" }, ["a", "b", "c"], ["a", "b"], false], | ||
[{ $lt: "5" }, [4, 3, 2, 1], [], false], | ||
[{ $lt: null }, [-3, -4], [], false], | ||
[{ $lt: new Date() }, [null], [], false], | ||
[ | ||
{ $lt: new Date() }, | ||
[new Date("2010-01-01")], | ||
[new Date("2010-01-01")], | ||
false | ||
], | ||
[ | ||
{ $lt: new Date(3) }, | ||
[new Date(1), new Date(2), new Date(3)], | ||
[new Date(1), new Date(2)] | ||
[new Date(1), new Date(2)], | ||
false | ||
], | ||
// $lte | ||
[{ $lte: 5 }, [3, 4, 5, 6], [3, 4, 5]], | ||
[{ $lte: "5" }, [4, 3, 2, 1], []], | ||
[{ $lte: "5" }, ["4", "3", "2"], ["4", "3", "2"]], | ||
[{ $lte: 5 }, [3, 4, 5, 6], [3, 4, 5], false], | ||
[{ $lte: "5" }, [4, 3, 2, 1], [], false], | ||
[{ $lte: "5" }, ["4", "3", "2"], ["4", "3", "2"], false], | ||
[ | ||
{ groups: { $lt: 5 } }, | ||
[{ groups: [1, 2, 3, 4] }, { groups: [7, 8] }], | ||
[{ groups: [1, 2, 3, 4] }] | ||
[{ groups: [1, 2, 3, 4] }], | ||
false | ||
], | ||
// $gt | ||
[{ $gt: 5 }, [3, 4, 5, 6], [6]], | ||
[{ $gt: null }, [3, 4], []], | ||
[{ $gt: "5" }, [6, 7, 8], []], | ||
[{ $gt: "5" }, ["6", "7", "8"], ["6", "7", "8"]], | ||
[{ $gt: 5 }, [3, 4, 5, 6], [6], false], | ||
[{ $gt: null }, [3, 4], [], false], | ||
[{ $gt: "5" }, [6, 7, 8], [], false], | ||
[{ $gt: "5" }, ["6", "7", "8"], ["6", "7", "8"], false], | ||
[ | ||
@@ -167,4 +179,4 @@ { groups: { $gt: 5 } }, | ||
// $gte | ||
[{ $gte: 5 }, [3, 4, 5, 6], [5, 6]], | ||
[{ $gte: "5" }, [4, 3, 2, 1], []], | ||
[{ $gte: 5 }, [3, 4, 5, 6], [5, 6], false], | ||
[{ $gte: "5" }, [4, 3, 2, 1], [], false], | ||
[ | ||
@@ -177,3 +189,3 @@ { groups: { $gte: 5 } }, | ||
// $mod | ||
[{ $mod: [2, 1] }, [1, 2, 3, 4, 5, 6], [1, 3, 5]], | ||
[{ $mod: [2, 1] }, [1, 2, 3, 4, 5, 6], [1, 3, 5], false], | ||
[ | ||
@@ -186,7 +198,8 @@ { groups: { $mod: [2, 0] } }, | ||
// $exists | ||
[{ $exists: false }, [0, false, undefined, null], []], | ||
[{ $exists: false }, [0, false, undefined, null], [], false], | ||
[ | ||
{ $exists: true }, | ||
[0, false, undefined, 1, {}], | ||
[0, false, undefined, 1, {}] | ||
[0, false, undefined, 1, {}], | ||
false | ||
], | ||
@@ -220,5 +233,5 @@ [ | ||
// TODO - {$in:[Date]} doesn't work - make it work? | ||
[{ $in: [0, false, 1, "1"] }, [0, 1, 2, 3, 4, false], [0, 1, false]], | ||
[{ $in: [1, "1", "2"] }, ["1", "2", "3"], ["1", "2"]], | ||
[{ $in: [new Date(1)] }, [new Date(1), new Date(2)], [new Date(1)]], | ||
[{ $in: [0, false, 1, "1"] }, [0, 1, 2, 3, 4, false], [0, 1, false], false], | ||
[{ $in: [1, "1", "2"] }, ["1", "2", "3"], ["1", "2"], false], | ||
[{ $in: [new Date(1)] }, [new Date(1), new Date(2)], [new Date(1)], false], | ||
[ | ||
@@ -237,3 +250,6 @@ { "a.b.status": { $in: [0] } }, | ||
[{ x: { b: "aaa" } }, { x: "bbb" }, { x: "ccc" }, { x: "aaa" }], | ||
[{ x: "bbb" }, { x: "aaa" }] | ||
[{ x: "bbb" }, { x: "aaa" }], | ||
// FIXME: #60 - cannot nest $ under $in | ||
false | ||
], | ||
@@ -247,5 +263,5 @@ [ | ||
// $nin | ||
[{ $nin: [0, false, 1, "1"] }, [0, 1, 2, 3, 4, false], [2, 3, 4]], | ||
[{ $nin: [1, "1", "2"] }, ["1", "2", "3"], ["3"]], | ||
[{ $nin: [new Date(1)] }, [new Date(1), new Date(2)], [new Date(2)]], | ||
[{ $nin: [0, false, 1, "1"] }, [0, 1, 2, 3, 4, false], [2, 3, 4], false], | ||
[{ $nin: [1, "1", "2"] }, ["1", "2", "3"], ["3"], false], | ||
[{ $nin: [new Date(1)] }, [new Date(1), new Date(2)], [new Date(2)], false], | ||
[ | ||
@@ -265,3 +281,6 @@ { "root.notDefined": { $nin: [1, 2, 3] } }, | ||
[{ x: { b: "aaa" } }, { x: "bbb" }, { x: "ccc" }, { x: "aaa" }], | ||
[{ x: { b: "aaa" } }, { x: "ccc" }] | ||
[{ x: { b: "aaa" } }, { x: "ccc" }], | ||
// FIXME: #61 - cannot nest $ under $in | ||
false | ||
], | ||
@@ -275,24 +294,31 @@ [ | ||
// $not | ||
[{ $not: false }, [0, false], [0]], | ||
[{ $not: 0 }, [0, false, 1, 2, 3], [false, 1, 2, 3]], | ||
[{ $not: { $in: [1, 2, 3] } }, [1, 2, 3, 4, 5, 6], [4, 5, 6]], // with expressions | ||
[{ $not: false }, [0, false], [0], false], | ||
[{ $not: 0 }, [0, false, 1, 2, 3], [false, 1, 2, 3], false], | ||
[{ $not: { $in: [1, 2, 3] } }, [1, 2, 3, 4, 5, 6], [4, 5, 6], false], // with expressions | ||
// $type | ||
[{ $type: Date }, [0, new Date(1)], [new Date(1)]], | ||
[{ $type: Number }, [0, false, 1], [0, 1]], | ||
[{ $type: Boolean }, [0, false, undefined], [false]], | ||
[{ $type: String }, ["1", 1, false], ["1"]], | ||
[{ $type: Date }, [0, new Date(1)], [new Date(1)], false], | ||
[{ $type: Number }, [0, false, 1], [0, 1], false], | ||
[{ $type: Boolean }, [0, false, undefined], [false], false], | ||
[{ $type: String }, ["1", 1, false], ["1"], false], | ||
// $all | ||
[{ $all: [1, 2, 3] }, [[1, 2, 3, 4], [1, 2, 4]], [[1, 2, 3, 4]]], | ||
[ | ||
{ $all: [1, 2, 3] }, | ||
[[1, 2, 3, 4], [1, 2, 4]], | ||
[[1, 2, 3, 4]], | ||
false // FIXME: operation passed in cannot be an Array | ||
], | ||
[ | ||
{ $all: [0, false] }, | ||
[[0, 1, 2], [0, false], ["0", "false"], undefined], | ||
[[0, false]] | ||
[[0, false]], | ||
false // FIXME: operation passed in cannot be an Array | ||
], | ||
[{ $all: ["1"] }, [[1]], []], | ||
[{ $all: ["1"] }, [[1]], [], false], | ||
[ | ||
{ $all: [new Date(1), new Date(2)] }, | ||
[[new Date(1), new Date(2)], [new Date(1)]], | ||
[[new Date(1), new Date(2)]] | ||
[[new Date(1), new Date(2)]], | ||
false // FIXME: operation passed in cannot be an Array | ||
], | ||
@@ -376,8 +402,8 @@ | ||
// $size | ||
[{ $size: 3 }, ["123", [1, 2, 3], "1"], ["123", [1, 2, 3]]], | ||
[{ $size: 1 }, ["123", [1, 2, 3], "1", undefined], ["1"]], | ||
[{ $size: 3 }, ["123", [1, 2, 3], "1"], ["123", [1, 2, 3]], false], | ||
[{ $size: 1 }, ["123", [1, 2, 3], "1", undefined], ["1"], false], | ||
// $or | ||
[{ $or: [1, 2, 3] }, [1, 2, 3, 4], [1, 2, 3]], | ||
[{ $or: [{ $ne: 1 }, 2] }, [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6]], | ||
[{ $or: [1, 2, 3] }, [1, 2, 3, 4], [1, 2, 3], false], | ||
[{ $or: [{ $ne: 1 }, 2] }, [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6], false], | ||
[ | ||
@@ -390,4 +416,4 @@ { $or: [{ a: 1 }, { b: 1 }] }, | ||
// $nor | ||
[{ $nor: [1, 2, 3] }, [1, 2, 3, 4], [4]], | ||
[{ $nor: [{ $ne: 1 }, 2] }, [1, 2, 3, 4, 5, 6], [1]], | ||
[{ $nor: [1, 2, 3] }, [1, 2, 3, 4], [4], false], | ||
[{ $nor: [{ $ne: 1 }, 2] }, [1, 2, 3, 4, 5, 6], [1], false], | ||
[ | ||
@@ -400,3 +426,3 @@ { $nor: [{ a: 1 }, { b: 1 }] }, | ||
// $and | ||
[{ $and: [{ $gt: 1 }, { $lt: 4 }] }, [1, 2, 3, 4], [2, 3]], | ||
[{ $and: [{ $gt: 1 }, { $lt: 4 }] }, [1, 2, 3, 4], [2, 3], false], | ||
[ | ||
@@ -407,8 +433,14 @@ { | ||
[{ a: 1, field: 1 }, { a: 2, field: "2" }], | ||
[{ a: 1, field: 1 }] | ||
[{ a: 1, field: 1 }], | ||
false | ||
], | ||
// $regex | ||
[{ $regex: "^a" }, ["a", "ab", "abc", "bc", "bcd"], ["a", "ab", "abc"]], | ||
[ | ||
{ $regex: "^a" }, | ||
["a", "ab", "abc", "bc", "bcd"], | ||
["a", "ab", "abc"], | ||
false | ||
], | ||
[ | ||
{ a: { $regex: "b|c" } }, | ||
@@ -428,3 +460,4 @@ [{ a: ["b"] }, { a: ["c"] }, { a: "c" }, { a: "d" }], | ||
["a", "Ab", "abc", "bc", "bcd"], | ||
["a", "Ab", "abc"] | ||
["a", "Ab", "abc"], | ||
false | ||
], | ||
@@ -438,5 +471,5 @@ [ | ||
// undefined | ||
[{ $regex: "a" }, [undefined, null, true, false, 0, "aa"], ["aa"]], | ||
[/a/, [undefined, null, true, false, 0, "aa"], ["aa"]], | ||
[/.+/, [undefined, null, true, false, 0, "aa", {}], ["aa"]], | ||
[{ $regex: "a" }, [undefined, null, true, false, 0, "aa"], ["aa"], false], | ||
[/a/, [undefined, null, true, false, 0, "aa"], ["aa"], false], | ||
[/.+/, [undefined, null, true, false, 0, "aa", {}], ["aa"], false], | ||
@@ -458,3 +491,4 @@ // Multiple conditions on an undefined root | ||
[{ v: 1 }, { v: 2 }], | ||
[{ v: 1 }] | ||
[{ v: 1 }], | ||
false | ||
], | ||
@@ -473,3 +507,3 @@ [{ $where: "this.v === 1" }, [{ v: 1 }, { v: 2 }], [{ v: 1 }]], | ||
], | ||
[{ a: { b: 1, c: 2 } }, { a: [{ b: 1, c: 2, d: 3 }] }] | ||
[{ a: [{ b: 1, c: 2, d: 3 }] }] | ||
], | ||
@@ -479,7 +513,8 @@ [ | ||
[ | ||
{ 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: 3, d: 3 }] }, | ||
[{ a: [{ b: 2, c: 3 }] }] | ||
], | ||
[[{ a: { b: 2, c: 3 } }]] | ||
[[{ a: [{ b: 2, c: 3 }] }]], | ||
false | ||
], | ||
@@ -496,2 +531,28 @@ [ | ||
], | ||
// addresses: https://github.com/crcn/sift.js/issues/183 | ||
[ | ||
{ | ||
bills: { | ||
$elemMatch: { | ||
month: "july", | ||
value: { $gt: 500 } | ||
} | ||
} | ||
}, | ||
[ | ||
{ | ||
bills: [ | ||
{ month: "july", value: 200 }, | ||
{ month: "august", value: 1000 } | ||
] | ||
}, | ||
{ | ||
bills: [ | ||
{ month: "july", value: 200 }, | ||
{ month: "august", value: 1000 } | ||
] | ||
} | ||
], | ||
[] | ||
], | ||
@@ -501,8 +562,3 @@ // dot-notation | ||
{ "a.b": /c/ }, | ||
[ | ||
{ a: { b: "c" } }, | ||
{ a: { b: "cd" } }, | ||
{ "a.b": "c" }, | ||
{ a: { b: "e" } } | ||
], | ||
[{ a: { b: "c" } }, { a: { b: "cd" } }, { a: { b: "e" } }], | ||
[{ a: { b: "c" } }, { a: { b: "cd" } }] | ||
@@ -555,3 +611,8 @@ ], | ||
// ], | ||
[{ $in: [{}] }, [{}, {}], [{}, {}]], | ||
[ | ||
{ $in: [{}] }, | ||
[{}, {}], | ||
[{}, {}], | ||
false // FIXME: unknown top level operator: $in | ||
], | ||
@@ -587,4 +648,5 @@ // based on https://gist.github.com/jdnichollsc/00ea8cf1204b17d9fb9a991fbd1dfee6 | ||
var matchArray = operation[2]; | ||
var testWithMongo = operation[3]; | ||
it(i + ": " + JSON.stringify(filter), function() { | ||
it(i + ": " + JSON.stringify(filter), async function() { | ||
assert.equal( | ||
@@ -594,4 +656,39 @@ JSON.stringify(array.filter(sift(filter))), | ||
); | ||
if (process.env.VALIDATE_WITH_MONGODB && testWithMongo !== false) { | ||
await testNativeQuery(filter, array, matchArray); | ||
} | ||
}); | ||
}); | ||
}); | ||
async function testNativeQuery(filter, array, matchArray) { | ||
const url = "mongodb://localhost:27017"; | ||
const client = await promisify(MongoClient.connect.bind(MongoClient))(url); | ||
const db = client.db("sift--test"); | ||
// console.log(db.dropDatabase); | ||
const collection = await promisify(db.createCollection.bind(db))("items"); | ||
// some items can't be inserted like [null] | ||
await promisify(collection.insertMany.bind(collection))(array); | ||
const search = collection.find(filter); | ||
const results = await promisify(search.toArray.bind(search))(); | ||
assert.equal( | ||
JSON.stringify( | ||
results.map(result => { | ||
const copy = { ...result }; | ||
delete copy._id; | ||
return copy; | ||
}) | ||
), | ||
JSON.stringify(matchArray) | ||
); | ||
await promisify(db.dropDatabase.bind(db))(); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
325367
3570
16
6