Comparing version 0.8.0 to 0.9.0
@@ -0,0 +0,0 @@ "use strict"; |
@@ -1,3 +0,3 @@ | ||
/*! jsexpr 2020-05-04 */ | ||
/*! jsexpr 2020-10-23 */ | ||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function i(u,a,c){function f(n,t){if(!a[n]){if(!u[n]){var r="function"==typeof require&&require;if(!t&&r)return r(n,!0);if(l)return l(n,!0);var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}var o=a[n]={exports:{}};u[n][0].call(o.exports,function(t){return f(u[n][1][t]||t)},o,o.exports,i,u,a,c)}return a[n].exports}for(var l="function"==typeof require&&require,t=0;t<c.length;t++)f(c[t]);return f}({1:[function(n,r,e){(function(){this.jsexpr;var t=n("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=t),e.jsexpr=t),"undefined"!=typeof window&&(window.jsexpr=t)}).call(this)},{"./index.js":2}],2:[function(t,n,r){var e=t("./lib");n.exports=e},{"./lib":4}],3:[function(require,module,exports){var extend=require("extend");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}","g"),RX_JSON_TOKEN=new RegExp("^\\"+token+"\\{JSON(:(\\d+|([^:]+(:(\\d+))?)))?\\}$"),CACHE={};function cacheeval(obj,key){if(!CACHE[key]){var rkey=key.replace(/'/g,"\\'"),rx=/^[a-zA-Z$_@]/,fn=eval("(function(){\n\t\t\t\tlet rx = /^[a-zA-Z$_]/;\n\t\t\t\treturn '"+rkey+"'.startsWith('this.') || '"+rkey+"'=='this' || !rx.test('"+rkey+"')?\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r="+key+";}\n\t\t\t\t\t\tcatch(err){}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t} :\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=this."+(rx.test(key)?key:"$___$")+";}\n\t\t\t\t\t\tcatch(err){try{r="+key+";}catch(err){}}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t}\n\t\t\t})()");CACHE[key]=fn}return CACHE[key].call(obj)}function fneval(obj,key){try{return eval("this."+key)}catch(t){return}}function fnassign(path){return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj."+path+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()")}var EVALS={eval:function(t,n){var r=fneval.call(t,t,n);return void 0===r?"":r},iteval:function(n,t){t.split(".").forEach(function(t){null!=n&&null!=n&&(n=n[t])});var r=n||void 0;return void 0===r?"":r},ceval:function(t,n){var r=cacheeval(t,n);return void 0===r?"":r},valwalk:function(t,n,r){if(!t)return t;for(var e in t){var o=r+(r?".":"")+e,i=n[o];void 0!==i?t[e]=i:"object"==_typeof(t[e])&&EVALS.valwalk(t[e],n,o)}return t}};function parse(r,n){n=n||"ceval";var t=r.match(RX);t&&t.forEach(function(t){var n=t.replace(RX_RPL_PARSE,"$1").trim().replace(/'/g,"\\'");r=r.replace(t,"__val(entry,'"+n+"')")});var e=new Function("entry","__val","return ("+r+")");return function(t){return e(t,EVALS[n])}}function tokens(o,i){if(i=EVALS[i||"ceval"],RX_JSON_TOKEN.test(o)){var t=o.replace(RX_RPL_TOKEN,"").split(":"),n=t[1],r=t[2];2==t.length?isNaN(n)?r=2:(n="this",r=t[1]):1==t.length&&(n="this",r=2),r=parseInt(r);var e=tokens("${"+n+"}");return function(t){return JSON.stringify(e(t),null,r)}}var u,a=[];return(o.match(RX)||[]).forEach(function(t){var n=o.indexOf(t),r=o.substring(0,n),e=t.replace(RX_RPL_TOKEN,"");o=o.substring(n+t.length),a.push(r),a.push(function(t){return i(t,e)})}),a.push(o),a=a.filter(function(t){return""!=t}),1<(u=a.length)?function(t){for(var n="",r=0;r<u;r++){var e=a[r];n+="string"==typeof e?e:e(t)}return n}:function(t){var n=a[0];return"string"==typeof n?n:n(t)}}function jsontokens(o){var i,u=[];return function e(o,i){o&&Object.keys(o).forEach(function(t){var n=i+(i?".":"")+t,r=o[t];"string"==typeof r?u.push({path:n,fn:tokens(r)}):e(r,n)})}(o,""),i=u.length,function(t){for(var n={},r=0;r<i;r++){var e=u[r];n[e.path]=e.fn(t)}return EVALS.valwalk(extend(!0,{},o),n,"")}}function exprfn(n,t){return"number"==typeof n?function(t){return n}:"object"==(void 0===n?"undefined":_typeof(n))?jsontokens(n,t):tokens(n)}function traverse(t,n){for(var r in t)t[r]=n(t,r,t[r]);for(var e in t)"object"==_typeof(t[e])&&traverse(t[e],n)}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn,traverse:traverse}}module.exports=instance},{extend:5}],4:[function(t,n,r){var e=t("./expression"),o=e("$");o.newInstance=function(t){return e(t)},n.exports=o},{"./expression":3}],5:[function(t,n,r){var o=Object.prototype.hasOwnProperty,i=Object.prototype.toString,e=Object.defineProperty,u=Object.getOwnPropertyDescriptor,s=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},p=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var n,r=o.call(t,"constructor"),e=t.constructor&&t.constructor.prototype&&o.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!e)return!1;for(n in t);return void 0===n||o.call(t,n)},v=function(t,n){e&&"__proto__"===n.name?e(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},y=function(t,n){if("__proto__"===n){if(!o.call(t,n))return;if(u)return u(t,n).value}return t[n]};n.exports=function t(){var n,r,e,o,i,u,a=arguments[0],c=1,f=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[1]||{},c=2),(null==a||"object"!==(void 0===a?"undefined":_typeof(a))&&"function"!=typeof a)&&(a={});c<f;++c)if(null!=(n=arguments[c]))for(r in n)e=y(a,r),a!==(o=y(n,r))&&(l&&o&&(p(o)||(i=s(o)))?(i?(i=!1,u=e&&s(e)?e:[]):u=e&&p(e)?e:{},v(a,{name:r,newValue:t(l,u,o)})):void 0!==o&&v(a,{name:r,newValue:o}));return a}},{}]},{},[1]); | ||
"use strict";var _typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};!function o(i,a,s){function c(t,n){if(!a[t]){if(!i[t]){var r="function"==typeof require&&require;if(!n&&r)return r(t,!0);if(f)return f(t,!0);var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}var u=a[t]={exports:{}};i[t][0].call(u.exports,function(n){return c(i[t][1][n]||n)},u,u.exports,o,i,a,s)}return a[t].exports}for(var f="function"==typeof require&&require,n=0;n<s.length;n++)c(s[n]);return c}({1:[function(t,r,e){(function(){this.jsexpr;var n=t("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=n),e.jsexpr=n),"undefined"!=typeof window&&(window.jsexpr=n)}).call(this)},{"./index.js":2}],2:[function(n,t,r){var e=n("./lib");t.exports=e},{"./lib":4}],3:[function(require,module,exports){var extend=require("extend"),Mingo=require("mingo");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}","g"),RX_JSON_TOKEN=new RegExp("^\\"+token+"\\{JSON(:(\\d+|([^:]+(:(\\d+))?)))?\\}$"),CACHE={};function cacheeval(obj,key){if(!CACHE[key]){var rkey=key.replace(/'/g,"\\'"),rx=/^[a-zA-Z$_@]/,fn=eval("(function(){\n\t\t\t\tlet rx = /^[a-zA-Z$_]/;\n\t\t\t\treturn '"+rkey+"'.startsWith('this.') || '"+rkey+"'=='this' || !rx.test('"+rkey+"')?\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r="+key+";}\n\t\t\t\t\t\tcatch(err){}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t} :\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=this."+(rx.test(key)?key:"$___$")+";}\n\t\t\t\t\t\tcatch(err){try{r="+key+";}catch(err){}}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t}\n\t\t\t})()");CACHE[key]=fn}return CACHE[key].call(obj)}function fneval(obj,key){try{return eval("this."+key)}catch(n){return}}function fnassign(path){return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj."+path+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()")}var EVALS={eval:function(n,t){var r=fneval.call(n,n,t);return void 0===r?"":r},iteval:function(t,n){n.split(".").forEach(function(n){null!=t&&null!=t&&(t=t[n])});var r=t||void 0;return void 0===r?"":r},ceval:function(n,t){var r=cacheeval(n,t);return void 0===r?"":r},valwalk:function(n,t,r){if(!n)return n;for(var e in n){var u=r+(r?".":"")+e,o=t[u];void 0!==o?n[e]=o:"object"==_typeof2(n[e])&&EVALS.valwalk(n[e],t,u)}return n}};function parse(r,t){t=t||"ceval";var n=r.match(RX);n&&n.forEach(function(n){var t=n.replace(RX_RPL_PARSE,"$1").trim().replace(/'/g,"\\'");r=r.replace(n,"__val(entry,'"+t+"')")});var e=new Function("entry","__val","return ("+r+")");return function(n){return e(n,EVALS[t])}}function tokens(u,o){if(o=EVALS[o||"ceval"],RX_JSON_TOKEN.test(u)){var n=u.replace(RX_RPL_TOKEN,"").split(":"),t=n[1],r=n[2];2==n.length?r=isNaN(t)?2:(t="this",n[1]):1==n.length&&(t="this",r=2),r=parseInt(r);var e=tokens("${"+t+"}");return function(n){return JSON.stringify(e(n),null,r)}}var i,a=[];return(u.match(RX)||[]).forEach(function(n){var t=u.indexOf(n),r=u.substring(0,t),e=n.replace(RX_RPL_TOKEN,"");u=u.substring(t+n.length),a.push(r),a.push(function(n){return o(n,e)})}),a.push(u),a=a.filter(function(n){return""!=n}),1<(i=a.length)?function(n){for(var t="",r=0;r<i;r++){var e=a[r];t+="string"==typeof e?e:e(n)}return t}:function(n){var t=a[0];return"string"==typeof t?t:t(n)}}function jsontokens(u){var o,i=[];return function e(u,o){u&&Object.keys(u).forEach(function(n){var t=o+(o?".":"")+n,r=u[n];"string"==typeof r?i.push({path:t,fn:tokens(r)}):e(r,t)})}(u,""),o=i.length,function(n){for(var t={},r=0;r<o;r++){var e=i[r];t[e.path]=e.fn(n)}return EVALS.valwalk(extend(!0,{},u),t,"")}}function mingotokens(n){var t=Array.isArray(n.$)?n.$:[n.$],e=new Mingo.Aggregator(t);return function(n){var t=Array.isArray(n),r=e.run(t?n:[n]);return!t&&r.length<=1?r[0]:r}}function exprfn(t,n){if("number"==typeof t)return function(n){return t};if("object"!=(void 0===t?"undefined":_typeof2(t)))return tokens(t);var r=extend({},t);delete r.$;var e=t.$?mingotokens(t,n):function(){return t},u=Object.keys(r).length?jsontokens(r,n):function(n){return n};return function(n){var t=e(n),r=u(t);return void 0!==r._&&1==Object.keys(r).length?r._:r}}function traverse(n,t){for(var r in n)n[r]=t(n,r,n[r]);for(var e in n)"object"==_typeof2(n[e])&&traverse(n[e],t)}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn,traverse:traverse}}module.exports=instance},{extend:6,mingo:7}],4:[function(n,t,r){var e=n("./expression"),u=(n("./mingo_ex"),e("$"));u.newInstance=function(n){return e(n)},t.exports=u},{"./expression":3,"./mingo_ex":5}],5:[function(n,t,r){var e=n("mingo"),u=n("./expression")("$"),i={},a={};e.addOperators(e.OP_QUERY,function(n){return{$starts:function(n,t,r){return r=Array.isArray(r)?r:[r],(t||"").startsWith(r[0])},$startsWith:function(n,t,r){return r=Array.isArray(r)?r:[r],(t||"").startsWith(r[0])},$ends:function(n,t,r){return r=Array.isArray(r)?r:[r],(t||"").endsWith(r[0])},$endsWith:function(n,t,r){return r=Array.isArray(r)?r:[r],(t||"").endsWith(r[0])},$contains:function(n,t,r){return r=Array.isArray(r)?r:[r],0<=(t||"").indexOf(r[0])}}}),e.addOperators(e.OP_EXPRESSION,function(o){return{$eval:function(n,t,r){return i[t]||(i[t]=u.eval(t)),i[t](n)},$expr:function(n,t,r){return a[t]||(a[t]=u.expr(t)),a[t](n)},$keyval:function(n,t,r){return o.computeValue(n,t).reduce(function(n,t){return n[t[0]]=t[1]||"_",n},{})},$trim:function(n,t,r){for(var e=new Set((t.chars||"").split("")),u=o.computeValue(n,t.input).split("");e.has(u[0]);)u.shift();for(;e.has(u[u.length-1]);)u.pop();return u.join("")},$starts:function(n,t,r){return(o.computeValue(n,t[0])||"").startsWith(t[1])},$startsWidth:function(n,t,r){return(o.computeValue(n,t[0])||"").startsWith(t[1])},$ends:function(n,t,r){return(o.computeValue(n,t[0])||"").endsWith(t[1])},$endsWith:function(n,t,r){return(o.computeValue(n,t[0])||"").endsWith(t[1])},$contains:function(n,t,r){return 0<=(o.computeValue(n,t[0])||"").indexOf(t[1])}}}),t.exports=e},{"./expression":3,mingo:7}],6:[function(n,t,r){var u=Object.prototype.hasOwnProperty,o=Object.prototype.toString,e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(n){return"function"==typeof Array.isArray?Array.isArray(n):"[object Array]"===o.call(n)},v=function(n){if(!n||"[object Object]"!==o.call(n))return!1;var t,r=u.call(n,"constructor"),e=n.constructor&&n.constructor.prototype&&u.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!r&&!e)return!1;for(t in n);return void 0===t||u.call(n,t)},h=function(n,t){e&&"__proto__"===t.name?e(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},p=function(n,t){if("__proto__"===t){if(!u.call(n,t))return;if(i)return i(n,t).value}return n[t]};t.exports=function n(){var t,r,e,u,o,i,a=arguments[0],s=1,c=arguments.length,f=!1;for("boolean"==typeof a&&(f=a,a=arguments[1]||{},s=2),(null==a||"object"!==(void 0===a?"undefined":_typeof2(a))&&"function"!=typeof a)&&(a={});s<c;++s)if(null!=(t=arguments[s]))for(r in t)e=p(a,r),a!==(u=p(t,r))&&(f&&u&&(v(u)||(o=l(u)))?(i=o?(o=!1,e&&l(e)?e:[]):e&&v(e)?e:{},h(a,{name:r,newValue:n(f,i,u)})):void 0!==u&&h(a,{name:r,newValue:u}));return a}},{}],7:[function(n,t,r){var e,u;e=this,u=function(){function e(n){return(e="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(n){return void 0===n?"undefined":_typeof2(n)}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":void 0===n?"undefined":_typeof2(n)})(n)}function i(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function u(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}function n(n,t,r){return t&&u(n.prototype,t),r&&u(n,r),n}function o(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(n)))return;var r=[],e=!0,u=!1,o=void 0;try{for(var i,a=n[Symbol.iterator]();!(e=(i=a.next()).done)&&(r.push(i.value),!t||r.length!==t);e=!0);}catch(n){u=!0,o=n}finally{try{e||null==a.return||a.return()}finally{if(u)throw o}}return r}(n,t)||function(n,t){if(!n)return;if("string"==typeof n)return a(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(n,t)}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}var s="null",c="undefined",f="boolean",l="number",v="string",h="date",p="regexp",d="array",y="object",g="function",m=[s,c,f,l,v,h,p],$="expression",_="group",b="pipeline",x="projection",k="query",O=function(){};Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(n,t){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),e=r.length>>>0;if(0===e)return!1;var u,o,i=0|t,a=Math.max(0<=i?i:e-Math.abs(i),0);for(;a<e;){if((u=r[a])===(o=n)||"number"==typeof u&&"number"==typeof o&&isNaN(u)&&isNaN(o))return!0;a++}return!1}});var w=Array.prototype.push;function j(n,t){n||J(t)}function A(n){switch(S(n)){case d:return n.map(A);case y:return K(n,A);default:return n}}function E(n){switch(S(n)){case d:return cn([],n);case y:return Object.assign({},n);default:return n}}function M(n){return null===n?"Null":void 0===n?"Undefined":n.constructor.name}function S(n){return M(n).toLowerCase()}function N(n){return S(n)===f}function R(n){return S(n)===v}function P(n){return S(n)===l}var I=Array.isArray||function(n){return!!n&&n.constructor===Array};function C(n){return!!n&&n.constructor===Object}function L(n){return n===Object(n)}function T(n){return S(n)===h}function q(n){return S(n)===p}function r(n){return S(n)===g}function V(n){return null==n}function U(n){return null===n}function t(n){return void 0===n}function D(n,t){return n.includes(t)}function F(n,t){return!D(n,t)}function z(n){return!!n}function W(n){return V(n)||I(n)&&0===n.length||C(n)&&0===H(n).length||!n}function X(n){return I(n)?n:[n]}function B(n,t){return n.hasOwnProperty(t)}function J(n){throw new Error(n)}var H=Object.keys;function Y(n,t,r){if(t=t.bind(r),I(n))for(var e=0,u=n.length;e<u&&!1!==t(n[e],e,n);e++);else for(var o in n)if(n.hasOwnProperty(o)&&!1===t(n[o],o,n))break}function K(n,t,r){t=t.bind(r);for(var e={},u=H(n),o=0;o<u.length;o++){var i=u[o];e[i]=t(n[i],i)}return e}function Q(t,r){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(t===O)return r;if(r===O)return t;var n=[t,r];if(!n.every(C)&&!n.every(I))throw Error("mismatched types. must both be array or object");if(e.flatten=e.flatten||!1,I(t))if(e.flatten){for(var u=0,o=0;u<t.length&&o<r.length;)t[u]=Q(t[u++],r[o++],e);for(;o<r.length;)t.push(r[o++])}else w.apply(t,r);else Object.keys(r).forEach(function(n){t.hasOwnProperty(n)?t[n]=Q(t[n],r[n],e):t[n]=r[n]});return t}function Z(r,e,u){return I(r)?r.reduce(e,u):(Y(r,function(n,t){return u=e(u,n,t,r)}),u)}function G(n,t){var r=t.map(un);return n.filter(function(n){return D(r,un(n))})}function nn(n){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1,o=[];return function n(t,r){for(var e=0,u=t.length;e<u;e++)I(t[e])&&(0<r||r<0)?n(t[e],Math.max(-1,r-1)):o.push(t[e])}(n,t),o}function tn(n,t){for(var r=[n],e=[t];0<r.length;)if((n=r.pop())!==(t=e.pop())){var u=S(n);if(u!==S(t)||u===g)return!1;switch(u){case d:if(n.length!==t.length)return!1;cn(r,n),cn(e,t);break;case y:var o=H(n),i=H(t);if(o.length!==i.length)return!1;o.sort(),i.sort();for(var a=0,s=o.length;a<s;a++){var c=o[a];if(c!==i[a])return!1;r.push(n[c]),e.push(t[c])}break;default:if(en(n)!==en(t))return!1}}return 0===r.length}function rn(n){var r={},e=[];return Y(n,function(n){var t=un(n);B(r,t)||(e.push(n),r[t]=0)}),e}function en(t){var n=S(t);switch(n){case f:case l:case p:return t.toString();case v:return JSON.stringify(t);case h:return t.toISOString();case s:case c:return n;case d:return"["+t.map(en)+"]";default:var r=n===y?"":"".concat(M(t)),e=H(t);return e.sort(),"".concat(r,"{")+e.map(function(n){return"".concat(en(n),":").concat(en(t[n]))})+"}"}}function un(n){if(V(n))return null;for(var t=0,r=en(n),e=r.length;e;)t=(t<<5)-t^r.charCodeAt(--e);return t>>>0}function on(n,t){return n<t?-1:t<n?1:0}function an(n,t,r){var e=[],u=[],o={};if(r=r||on,W(n))return n;for(var i=0;i<n.length;i++){var a=n[i],s=t(a,i);V(s)?u.push(a):(o[s]?o[s].push(a):o[s]=[a],e.push(s))}e.sort(r);for(var c=0;c<e.length;c++)cn(u,o[e[c]]);return u}function sn(n,u){var o={keys:[],groups:[]},i={};return Y(n,function(n){var t=u(n),r=un(t),e=-1;void 0===i[r]&&(e=o.keys.length,i[r]=e,o.keys.push(t),o.groups.push([])),e=i[r],o.groups[e].push(n)}),o}function cn(n,t){return w.apply(n,t),n}function fn(n,t){return L(n)?n[t]:void 0}function ln(n,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=0;return r.meta=r.meta||!1,n=D(m,S(n))?n:function e(n,u){for(var t=n,r=0;r<u.length;r++){var o=u[r];if(null===o.match(/^\d+$/)&&I(t)){if(0===r&&0<i)break;i+=1,u=u.slice(r),t=Z(t,function(n,t){var r=e(t,u);return void 0!==r&&n.push(r),n},[]);break}if(void 0===(t=fn(t,o)))break}return t}(n,t.split(".")),r.meta?{result:n,depth:i}:n}function vn(n,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.preserveMissingValues=r.preserveMissingValues||!1;var e,u,o=t.split("."),i=o[0],a=1===o.length||o.slice(1).join("."),s=null!==i.match(/^\d+$/),c=1<o.length;try{I(n)?s?(e=fn(n,Number(i)),c&&(e=vn(e,a,r)),e=[e]):(e=[],Y(n,function(n){u=vn(n,t,r),r.preserveMissingValues?(void 0===u&&(u=O),e.push(u)):void 0!==u&&e.push(u)})):(u=fn(n,i),c&&(u=vn(u,a,r)),j(void 0!==u),(e={})[i]=u)}catch(n){e=void 0}return e}function hn(n){if(I(n))for(var t=n.length-1;0<=t;t--)n[t]===O?n.splice(t,1):hn(n[t]);else if(C(n))for(var r in n)n.hasOwnProperty(r)&&hn(n[r]);return n}function pn(n,t,r){var e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],u=t.split("."),o=u[0],i=1===u.length||u.slice(1).join(".");1===u.length?r(n,o):(!0===e&&V(n[o])&&(n[o]={}),pn(n[o],i,r,e))}function dn(n,t,r){pn(n,t,function(n,t){n[t]=r},!0)}function yn(n,t){pn(n,t,function(n,t){I(n)&&/^\d+$/.test(t)?n.splice(parseInt(t),1):C(n)&&delete n[t]})}function gn(n){return!!n&&"$"===n[0]}function mn(n){if(D(m,S(n)))return q(n)?{$regex:n}:{$eq:n};if(L(n)){var t=H(n);if(!t.some(gn))return{$eq:n};if(D(t,"$regex")){var r=n.$regex,e=n.$options||"",u="";R(r)&&(u+=r.ignoreCase||0<=e.indexOf("i")?"i":"",u+=r.multiline||0<=e.indexOf("m")?"m":"",u+=r.global||0<=e.indexOf("g")?"g":"",r=new RegExp(r,u)),n.$regex=r,delete n.$options}}return n}function $n(n,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return V(r)?t<0?(t=Math.max(0,n.length+t),r=n.length-t+1):(r=t,t=0):(t<0&&(t=Math.max(0,n.length+t)),j(0<r,"Invalid argument value for $slice operator. Limit must be a positive number"),r+=t),n.slice(t,r)}function _n(n,t){var r=Z(n,function(n,t){return n+t},0),e=n.length||1,u=t?1:0,o=r/e;return Math.sqrt(Z(n,function(n,t){return n+Math.pow(t-o,2)},0)/(e-u))}var bn=function(){return Object.assign({computeValue:Sn,ops:En},{assert:j,clone:E,cloneDeep:A,each:Y,err:J,hashCode:un,getType:M,has:B,includes:D.bind(null),isArray:I,isBoolean:N,isDate:T,isEmpty:W,isEqual:tn,isFunction:r,isNil:V,isNull:U,isNumber:P,isObject:C,isRegExp:q,isString:R,isUndefined:t,keys:H,reduce:Z,resolve:ln,resolveObj:vn})},xn={key:"_id"};var kn={$$ROOT:function(n,t,r){return r.root},$$CURRENT:function(n,t,r){return n},$$REMOVE:function(n,t,r){}},On={$$KEEP:function(n){return n},$$PRUNE:function(){},$$DESCEND:function(r,e,u){return B(e,"$cond")&&Y(r,function(n,t){L(n)&&(I(n)?(o=[],Y(n,function(n){C(n)&&(n=Nn(n,e,u)),V(n)||o.push(n)})):o=Nn(n,e,u),V(o)?delete r[t]:r[t]=o)}),r;var o}},wn=H(kn),jn=H(On);function An(){return xn.key}function En(){return Z(Array.prototype.slice.call(arguments),function(n,t){return cn(n,H(Gt[t]))},[])}function Mn(r,n,e){if(B(Gt[_],n))return Gt[_][n](r,e);if(C(e)){var u={};return Y(e,function(n,t){if(u[t]=Mn(r,t,e[t]),B(Gt[_],t))return u=u[t],j(1===H(e).length,"Invalid $group expression '"+JSON.stringify(e)+"'"),!1}),u}}function Sn(r,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,u=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(u.root=u.root||r,B(Gt[$],n))return Gt[$][n](r,e,u);if(B(Gt[_],n))return r=Sn(r,e,null,u),j(I(r),n+" expression must resolve to an array"),Gt[_][n](r,null,u);if(R(e)&&0<e.length&&"$"===e[0]){if(D(wn,e))return kn[e](r,null,u);if(D(jn,e))return e;var t=wn.filter(function(n){return 0===e.indexOf(n+".")});return 1===t.length&&("$$ROOT"===(t=t[0])&&(r=u.root),e=e.substr(t.length)),ln(r,e.slice(1))}switch(S(e)){case d:return e.map(function(n){return Sn(r,n)});case y:var o={};return Y(e,function(n,t){if(o[t]=Sn(r,n,t,u),[$,_].some(function(n){return B(Gt[n],t)}))return j(1===H(e).length,"Invalid aggregation expression '"+JSON.stringify(e)+"'"),o=o[t],!1}),o;default:return e}}function Nn(n,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.root=r.root||n;var e=Sn(n,t,null,r);return D(jn,e)?On[e](n,t,r):e}function Rn(n,t,r){t=t||0;var e=Math.abs(n)===n?1:-1;n=Math.abs(n);var u=Math.trunc(n),o=n-u;if(0===t){var i=Math.trunc(10*o);r&&1==(1&u)&&5<=i&&u++}else if(0<t){var a=Math.pow(10,t),s=Math.trunc(o*a),c=Math.trunc(o*a*10)%10;r&&5<c&&(s+=1),u+=s/a}else if(t<0){var f=Math.pow(10,-1*t),l=u%f;if(u=Math.max(0,u-l),r&&-1===e){for(;10<l;)l-=l%10;0<u&&5<=l&&(u+=f)}}return u*e}function Pn(n){return n instanceof Dn?n:new Dn(n)}function In(n){return!!n&&"object"===e(n)&&Cn(n.next)}function Cn(n){return!!n&&"function"==typeof n}Pn.isIterator=In;var Ln=new Error,Tn=1,qn=2,Vn=3,Un=4;var Dn=function(){function o(n){if(i(this,o),this.__iteratees=[],this.__first=!1,this.__done=!1,this.__buf=[],Cn(n)&&(n={next:n}),In(n)){var t=n;n=function(){var n=t.next();if(n.done)throw Ln;return n.value}}else if(Array.isArray(n)){var r=n,e=r.length,u=0;n=function(){if(u<e)return r[u++];throw Ln}}else if(!Cn(n))throw new Error("Source is not iterable. Must be Array, Function or Object{next:Function}");var f,l,v,h,p,d;this.next=(f=n,l=this.__iteratees,v=this.__buf,h=!1,p=-1,d=0,function(n){n=n===v;try{n:for(;!h;){var t=f();p++;for(var r=-1,e=l.length,u=!1;++r<e;){var o=l[r],i=o.func;switch(o.type){case Tn:t=i(t,p);break;case qn:if(!i(t,p))continue n;break;case Vn:--o.func,o.func||(u=!0);break;case Un:--o.func,o.func||(s=r,c=(a=l).slice(s+1),a.splice(s),Array.prototype.push.apply(a,c));continue n;default:break n}}if(h=u,!n)return{value:t,done:!1};v[d++]=t}}catch(n){if(n!==Ln)throw n}var a,s,c;return{done:h=!0}})}return n(o,[{key:"_validate",value:function(){if(this.__first)throw new Error("Cannot add iteratee/transform after `first()`")}},{key:"_push",value:function(n){return this._validate(),this.__iteratees.push(n),this}},{key:"map",value:function(n){return this._push({type:Tn,func:n})}},{key:"filter",value:function(n){return this._push({type:qn,func:n})}},{key:"take",value:function(n){return 0<n?this._push({type:Vn,func:n}):this}},{key:"drop",value:function(n){return 0<n?this._push({type:Un,func:n}):this}},{key:"transform",value:function(n){this._validate();var t,r=this;return Pn(function(){return t||(t=Pn(n(r.value()))),t.next()})}},{key:"first",value:function(){return this.take(1),this.__first=!0,this}},{key:"value",value:function(){return this.__done||(this.__done=this.next(this.__buf).done),this.__first?this.__buf[0]:this.__buf}},{key:"each",value:function(n){for(;;){var t=this.next();if(t.done)break;if(!1===n(t.value))return!1}return!0}},{key:"reduce",value:function(n,t){var r=this.next(),e=0;for(void 0!==t||r.done||(t=r.value,r=this.next(),e++);!r.done;)t=n(t,r.value,e++),r=this.next();return t}},{key:"size",value:function(){return this.reduce(function(n,t){return++n},0)}}]),o}();"function"==typeof Symbol&&(Dn.prototype[Symbol.iterator]=function(){return this});var Fn=function(){function r(n,t){i(this,r),this.__operators=n,this.__options=t}return n(r,[{key:"stream",value:function(r,e){var u=this;r=Pn(r);var o=Gt[b];return W(this.__operators)||Y(this.__operators,function(n){var t=H(n);j(1===t.length&&D(En(b),t[0]),"invalid aggregation operator ".concat(t)),t=t[0],r=e&&e instanceof Xn?o[t].call(e,r,n[t],u.__options):o[t](r,n[t],u.__options)}),r}},{key:"run",value:function(n,t){return this.stream(n,t).value()}}]),r}();function zn(n,t,r){return j(I(t),"Aggregation pipeline must be an array"),new Fn(t,r).run(n)}var Wn=function(){function e(n,t,r){i(this,e),this.__filterFn=t.test.bind(t),this.__query=t,this.__source=n,this.__projection=r||t.__projection,this.__operators=[],this.__result=null,this.__stack=[],this.__options={}}return n(e,[{key:"_fetch",value:function(){return this.__result||(C(this.__projection)&&this.__operators.push({$project:this.__projection}),this.__result=Pn(this.__source).filter(this.__filterFn),0<this.__operators.length&&(this.__result=new Fn(this.__operators,this.__options).stream(this.__result,this.__query))),this.__result}},{key:"all",value:function(){return this._fetch().value()}},{key:"count",value:function(){return this.all().length}},{key:"skip",value:function(n){return this.__operators.push({$skip:n}),this}},{key:"limit",value:function(n){return this.__operators.push({$limit:n}),this}},{key:"sort",value:function(n){return this.__operators.push({$sort:n}),this}},{key:"collation",value:function(n){return this.__options.collation=n,this}},{key:"next",value:function(){if(this.__stack){if(0<this.__stack.length)return this.__stack.pop();var n=this._fetch().next();if(!n.done)return n.value;this.__stack=null}}},{key:"hasNext",value:function(){if(!this.__stack)return!1;if(0<this.__stack.length)return!0;var n=this._fetch().next();return n.done?this.__stack=null:this.__stack.push(n.value),!!this.__stack}},{key:"map",value:function(n){return this._fetch().map(n).value()}},{key:"forEach",value:function(n){this._fetch().each(n)}}]),e}();"function"==typeof Symbol&&(Wn.prototype[Symbol.iterator]=function(){return this._fetch()});var Xn=function(){function r(n,t){i(this,r),this.__criteria=n,this.__projection=t||{},this.__compiled=[],this._compile()}return n(r,[{key:"_compile",value:function(){var t,e=this;j(C(this.__criteria),"query criteria must be an object"),Y(this.__criteria,function(n,r){"$where"===r?t={field:r,expr:n}:"$expr"===r?e._processOperator(r,r,n):D(["$and","$or","$nor"],r)?e._processOperator(r,r,n):(j(!gn(r),"unknown top level operator: ".concat(r)),Y(n=mn(n),function(n,t){e._processOperator(r,t,n)})),C(t)&&e._processOperator(t.field,t.field,t.expr)})}},{key:"_processOperator",value:function(n,t,r){j(B(Gt[k],t),"invalid query operator ".concat(t," detected")),this.__compiled.push(Gt[k][t](n,r))}},{key:"test",value:function(n){for(var t=0,r=this.__compiled.length;t<r;t++)if(!this.__compiled[t](n))return!1;return!0}},{key:"find",value:function(n,t){return new Wn(n,this,t)}},{key:"remove",value:function(n){var r=this;return Z(n,function(n,t){return r.test(t)||n.push(t),n},[])}}]),r}();function Bn(n,t){if(tn(n,t))return!0;if(V(n)&&V(t))return!0;if(I(n)){var r=tn.bind(null,t);return n.some(r)||nn(n,1).some(r)}return!1}function Jn(n,t){return!Bn(n,t)}function Hn(n,t){return V(n)?t.some(U):0<G(X(n),t).length}function Yn(n,t){return!Hn(n,t)}function Kn(n,t){return tt(n,t,function(n,t){return n<t})}function Qn(n,t){return tt(n,t,function(n,t){return n<=t})}function Zn(n,t){return tt(n,t,function(n,t){return t<n})}function Gn(n,t){return tt(n,t,function(n,t){return t<=n})}function nt(n,t){if(I(n)&&!W(n)){var r=function(n){return n},e=t;H(t).every(gn)&&(e={temp:t},r=function(n){return{temp:n}});for(var u=new Xn(e),o=0,i=n.length;o<i;o++)if(u.test(r(n[o])))return!0}return!1}function tt(n,t,r){return X(n).some(function(n){return M(n)===M(t)&&r(n,t)})}function rt(e){return function(n,t){var r=Sn(n,t);return e(r[0],r[1])}}var et=rt(Bn),ut=rt(Jn),ot=rt(Zn),it=rt(Kn),at=rt(Gn),st=rt(Qn),ct=rt(Yn);function ft(n,t){var r=Sn(n,t),e=new Date(r.getFullYear(),0,0),u=r-e;return Math.round(u/864e5)}function lt(n,t){return Sn(n,t).getDate()}function vt(n,t){return Sn(n,t).getDay()+1}function ht(n,t){return Sn(n,t).getFullYear()}function pt(n,t){return Sn(n,t).getMonth()+1}function dt(n,t){var r=Sn(n,t);(r=new Date(+r)).setHours(0,0,0),r.setDate(r.getDate()+4-(r.getDay()||7));var e=new Date(r.getFullYear(),0,1);return Math.floor(((r-e)/864e5+1)/7)}function yt(n,t){return Sn(n,t).getUTCHours()}function gt(n,t){return Sn(n,t).getMinutes()}function mt(n,t){return Sn(n,t).getSeconds()}function $t(n,t){return Sn(n,t).getMilliseconds()}var _t={"%Y":[ht,4],"%m":[pt,2],"%d":[lt,2],"%H":[yt,2],"%M":[gt,2],"%S":[mt,2],"%L":[$t,3],"%j":[ft,3],"%w":[vt,1],"%U":[dt,2],"%%":"%"};function bt(n,t){var r=Sn(n,t),e=r[0],u=r[1],o=r[2];return R(e)?u<0?"":o<0?e.substr(u):e.substr(u,o):""}var xt=[192,224,240];function kt(n){if(n<128)return[n];for(var t=(n<2048?1:n<65536&&2)||3,r=[(n>>6*t)+xt[t-1]];0<t;)r.push(128|n>>6*--t&63);return r}var Ot=Object.freeze({__proto__:null,$abs:function(n,t){var r=Sn(n,t);return null==r?null:Math.abs(r)},$add:function(n,t){var r=Sn(n,t),e=!1,u=Z(r,function(n,t){return T(t)&&(j(!e,"'$add' can only have one date value"),e=!0,t=t.getTime()),n+=t},0);return e?new Date(u):u},$ceil:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)||isNaN(r),"$ceil expression must resolve to a number."),Math.ceil(r))},$divide:function(n,t){var r=Sn(n,t);return r[0]/r[1]},$exp:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)||isNaN(r),"$exp expression must resolve to a number."),Math.exp(r))},$floor:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)||isNaN(r),"$floor expression must resolve to a number."),Math.floor(r))},$ln:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)||isNaN(r),"$ln expression must resolve to a number."),Math.log(r))},$log:function(n,t){var r=Sn(n,t),e="$log expression must resolve to array(2) of numbers";return j(I(r)&&2===r.length,e),r.some(V)?null:(j(r.some(isNaN)||r.every(P),e),Math.log10(r[0])/Math.log10(r[1]))},$log10:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)||isNaN(r),"$log10 expression must resolve to a number."),Math.log10(r))},$mod:function(n,t){var r=Sn(n,t);return r[0]%r[1]},$multiply:function(n,t){return Z(Sn(n,t),function(n,t){return n*t},1)},$pow:function(n,t){var r=Sn(n,t);return j(I(r)&&2===r.length&&r.every(P),"$pow expression must resolve to array(2) of numbers"),j(!(0===r[0]&&r[1]<0),"$pow cannot raise 0 to a negative exponent"),Math.pow(r[0],r[1])},$round:function(n,t){var r=Sn(n,t),e=r[0],u=r[1];return V(e)||isNaN(e)||Math.abs(e)===1/0?e:(j(P(e),"$round expression must resolve to a number."),Rn(e,u,!0))},$sqrt:function(n,t){var r=Sn(n,t);return V(r)?null:(j(P(r)&&0<r||isNaN(r),"$sqrt expression must resolve to non-negative number."),Math.sqrt(r))},$subtract:function(n,t){var r=Sn(n,t);return r[0]-r[1]},$trunc:function(n,t){var r=Sn(n,t),e=r[0],u=r[1];return V(e)||isNaN(e)||Math.abs(e)===1/0?e:(j(P(e),"$trunc expression must resolve to a number."),j(V(u)||P(u)&&-20<u&&u<100,"$trunc expression has invalid place"),Rn(e,u,!1))},$arrayElemAt:function(n,t){var r=Sn(n,t);j(I(r)&&2===r.length,"$arrayElemAt expression must resolve to array(2)"),j(I(r[0]),"First operand to $arrayElemAt must resolve to an array"),j(P(r[1]),"Second operand to $arrayElemAt must resolve to an integer");var e=r[1];return r=r[0],e<0&&Math.abs(e)<=r.length?r[e+r.length]:0<=e&&e<r.length?r[e]:void 0},$arrayToObject:function(n,t){var r=Sn(n,t);return j(I(r),"$arrayToObject expression must resolve to an array"),Z(r,function(n,t){return I(t)&&2==t.length?n[t[0]]=t[1]:(j(C(t)&&B(t,"k")&&B(t,"v"),"$arrayToObject expression is invalid."),n[t.k]=t.v),n},{})},$concatArrays:function(n,t){var r=Sn(n,t,null);return j(I(r),"$concatArrays must resolve to an array"),r.some(V)?null:r.reduce(function(n,t){return cn(n,t)},[])},$filter:function(n,t){var r=Sn(n,t.input),e=t.as,u=t.cond;return j(I(r),"$filter 'input' expression must resolve to an array"),r.filter(function(n){var t={};return t["$"+e]=n,!0===Sn(t,u)})},$in:function(n,t){var r=Sn(n,t[0]),e=Sn(n,t[1]);return j(I(e),"$in second argument must be an array"),e.some(tn.bind(null,r))},$indexOfArray:function(n,t){var r=Sn(n,t);if(V(r))return null;var e=r[0],u=r[1];if(V(e))return null;j(I(e),"$indexOfArray expression must resolve to an array.");var o=r[2]||0,i=r[3];return V(i)&&(i=e.length),i<o?-1:(j(0<=o&&0<=i,"$indexOfArray expression is invalid"),(0<o||i<e.length)&&(e=e.slice(o,i)),e.findIndex(tn.bind(null,u))+o)},$isArray:function(n,t){return I(Sn(n,t[0]))},$map:function(t,n){var r=Sn(t,n.input);j(I(r),"$map 'input' expression must resolve to an array");var e=n.as,u=n.in,o="$"+e;return r.map(function(n){return t[o]=n,Sn(t,u)})},$objectToArray:function(n,t){var r=Sn(n,t);j(C(r),"$objectToArray expression must resolve to an object");var e=[];return Y(r,function(n,t){return e.push({k:t,v:n})}),e},$range:function(n,t){for(var r=Sn(n,t),e=r[0],u=r[1],o=r[2]||1,i=[];e<u&&0<o||u<e&&o<0;)i.push(e),e+=o;return i},$reduce:function(n,t){var r=Sn(n,t.input),e=Sn(n,t.initialValue),u=t.in;return V(r)?null:(j(I(r),"$reduce 'input' expression must resolve to an array"),Z(r,function(n,t){return Sn({$value:n,$this:t},u)},e))},$reverseArray:function(n,t){var r=Sn(n,t);if(V(r))return null;j(I(r),"$reverseArray expression must resolve to an array");var e=[];return cn(e,r),e.reverse(),e},$size:function(n,t){var r=Sn(n,t);return I(r)?r.length:void 0},$slice:function(n,t){var r=Sn(n,t);return $n(r[0],r[1],r[2])},$zip:function(n,t){var e=Sn(n,t.inputs),r=t.useLongestLength||!1;j(I(e),"'inputs' expression must resolve to an array"),j(N(r),"'useLongestLength' must be a boolean"),I(t.defaults)&&j(z(r),"'useLongestLength' must be set to true to use 'defaults'");for(var u=0,o=0,i=e.length;o<i;o++){var a=e[o];if(V(a))return null;j(I(a),"'inputs' expression values must resolve to an array or null"),u=r?Math.max(u,a.length):Math.min(u||a.length,a.length)}for(var s=[],c=t.defaults||[],f=function(r){var n=e.map(function(n,t){return V(n[r])?c[t]||null:n[r]});s.push(n)},l=0;l<u;l++)f(l);return s},$mergeObjects:function(n,t){var r=Sn(n,t);return I(r)?Z(r,function(n,t){return Object.assign(n,t)},{}):{}},$and:function(n,t){var r=Sn(n,t);return z(r)&&r.every(z)},$or:function(n,t){var r=Sn(n,t);return z(r)&&r.some(z)},$not:function(n,t){return!Sn(n,t[0])},$eq:et,$ne:ut,$gt:ot,$lt:it,$gte:at,$lte:st,$nin:ct,$cmp:function(n,t){var r=Sn(n,t);return r[0]>r[1]?1:r[0]<r[1]?-1:0},$cond:function(n,t){var r,e,u,o="$cond: invalid arguments";return u=I(t)?(j(3===t.length,o),r=t[0],e=t[1],t[2]):(j(C(t),o),r=t.if,e=t.then,t.else),Sn(n,Sn(n,r)?e:u)},$switch:function(t,n){var r="Invalid arguments for $switch operator";j(n.branches,r);var e=n.branches.find(function(n){return j(n.case&&n.then,r),Sn(t,n.case)});return e?Sn(t,e.then):(j(n.default,r),Sn(t,n.default))},$ifNull:function(n,t){j(I(t)&&2===t.length,"$ifNull expression must resolve to array(2)");var r=Sn(n,t);return V(r[0])?r[1]:r[0]},$dayOfYear:ft,$dayOfMonth:lt,$dayOfWeek:vt,$year:ht,$month:pt,$week:dt,$hour:yt,$minute:gt,$second:mt,$millisecond:$t,$dateToString:function(n,t){for(var r,e,u=t.format,o=Sn(n,t.date),i=u.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g),a=0,s=i.length;a<s;a++){var c=_t[i[a]],f=c;if(I(c)){var l=c[0],v=c[1];r=l(n,o),e=v,f=new Array(Math.max(e-String(r).length+1,0)).join("0")+r}u=u.replace(i[a],f)}return u},$literal:function(n,t){return t},$setEquals:function(n,t){var r=Sn(n,t),e=rn(r[0]),u=rn(r[1]);return e.length===u.length&&e.length===G(e,u).length},$setIntersection:function(n,t){var r=Sn(n,t);return G(r[0],r[1])},$setDifference:function(n,t){var r=Sn(n,t);return r[0].filter(F.bind(null,r[1]))},$setUnion:function(n,t){var r,e,u=Sn(n,t);return r=u[0],e=u[1],cn(cn([],r),e.filter(F.bind(null,r)))},$setIsSubset:function(n,t){var r=Sn(n,t);return G(r[0],r[1]).length===r[0].length},$anyElementTrue:function(n,t){return Sn(n,t)[0].some(z)},$allElementsTrue:function(n,t){return Sn(n,t)[0].every(z)},$concat:function(n,t){var r=Sn(n,t);return[null,void 0].some(D.bind(null,r))?null:r.join("")},$indexOfBytes:function(n,t){var r=Sn(n,t),e="$indexOfBytes expression resolves to invalid an argument";if(V(r[0]))return null;j(R(r[0])&&R(r[1]),e);var u=r[0],o=r[1],i=r[2],a=r[3],s=V(i)||P(i)&&0<=i&&Math.round(i)===i;if(j(s=s&&(V(a)||P(a)&&0<=a&&Math.round(a)===a),e),i=i||0,(a=a||u.length)<i)return-1;var c=u.substring(i,a).indexOf(o);return-1<c?c+i:c},$split:function(n,t){var r=Sn(n,t);return V(r[0])?null:(j(r.every(R),"$split expression must result to array(2) of strings"),r[0].split(r[1]))},$strLenBytes:function(n,t){return~-encodeURI(Sn(n,t)).split(/%..|./).length},$strLenCP:function(n,t){return Sn(n,t).length},$strcasecmp:function(n,t){var r=Sn(n,t),e=r[0],u=r[1];return tn(e,u)||r.every(V)?0:(j(r.every(R),"$strcasecmp must resolve to array(2) of strings"),e=e.toUpperCase(),((u=u.toUpperCase())<e?1:e<u&&-1)||0)},$substrBytes:function(n,t){var r=Sn(n,t),e=r[0],u=r[1],o=r[2];j(R(e)&&P(u)&&0<=u&&P(o)&&0<=o,"$substrBytes: invalid arguments");for(var i=function(n){for(var t=[],r=0,e=n.length;r<e;r++)t.push(kt(n.codePointAt(r)));return t}(e),a=[],s=0,c=0;c<i.length;c++)a.push(s),s+=i[c].length;var f=a.indexOf(u),l=a.indexOf(u+o);return j(-1<f&&-1<l,"$substrBytes: invalid range, start or end index is a UTF-8 continuation byte."),e.substring(f,l)},$substr:bt,$substrCP:function(n,t){return bt(n,t)},$toLower:function(n,t){var r=Sn(n,t);return W(r)?"":r.toLowerCase()},$toUpper:function(n,t){var r=Sn(n,t);return W(r)?"":r.toUpperCase()},$let:function(r,n){var e=n.vars,t=n.in;return Y(H(e),function(n){var t=Sn(r,e[n]);r["$"+n]=t}),Sn(r,t)}});function wt(n,t){return V(t)?n:n.map(function(n){return Sn(n,t)})}var jt=Object.freeze({__proto__:null,$addToSet:function(n,t){return rn(wt(n,t))},$avg:function(n,t){var r=wt(n,t).filter(P);return Z(r,function(n,t){return n+t},0)/(r.length||1)},$first:function(n,t){return 0<n.length?Sn(n[0],t):void 0},$last:function(n,t){return 0<n.length?Sn(n[n.length-1],t):void 0},$max:function(n,t){return Z(wt(n,t),function(n,t){return V(n)||n<t?t:n},void 0)},$mergeObjects:function(n,r){return Z(n,function(n,t){return Object.assign(n,Sn(t,r))},{})},$min:function(n,t){return Z(wt(n,t),function(n,t){return V(n)||t<n?t:n},void 0)},$push:wt,$stdDevPop:function(n,t){return _n(wt(n,t).filter(P),!1)},$stdDevSamp:function(n,t){return _n(wt(n,t).filter(P),!0)},$sum:function(n,t){return I(n)?P(t)?n.length*t:Z(wt(n,t).filter(P),function(n,t){return n+t},0):0}});function At(n,u,t){var o=H(u);return 0===o.length?n:n.map(function(r){var e=A(r);return Y(o,function(n){var t=Sn(r,u[n]);dn(e,n,t)}),e})}var Et=At;function Mt(n,o,t){var i=An(),r=o[i];return n.transform(function(n){var e=sn(n,function(n){return Sn(n,r,r)});delete(o=E(o))[i];var u=-1,t=e.keys.length;return function(){if(++u===t)return{done:!0};var n=e.keys[u],r={};return void 0!==n&&(r[i]=n),Y(o,function(n,t){r[t]=Mn(e.groups[u],t,n)}),{value:r,done:!1}}})}function St(n){var r=An(),e=[!1,!1];Y(n,function(n,t){t!==r&&(0===n||!1===n?e[0]=!0:1!==n&&!0!==n||(e[1]=!0),j(!(e[0]&&e[1]),"Projection cannot have a mix of inclusion and exclusion."))})}function Nt(n,o,t){if(W(o)||!C(o))return n;var i=on,r=(t=t||{}).collation;return C(r)&&R(r.locale)&&(i=function(n){var t={sensitivity:Rt[n.strength||3],caseFirst:"off"===n.caseFirst?"false":n.caseFirst||"false",numeric:n.numericOrdering||!1,ignorePunctuation:"shifted"===n.alternate};!0===(n.caseLevel||!1)&&("base"===t.sensitivity&&(t.sensitivity="case"),"accent"===t.sensitivity&&(t.sensitivity="variant"));var e=new Intl.Collator(n.locale,t);return function(n,t){if(!R(n)||!R(t))return on(n,t);var r=e.compare(n,t);return r<0?-1:0<r?1:0}}(r)),n.transform(function(u){return Y(H(o).reverse(),function(t){var r=sn(u,function(n){return ln(n,t)}),e={},n=an(r.keys,function(n,t){return e[n]=t,n},i);-1===o[t]&&n.reverse(),u=[],Y(n,function(n){return cn(u,r.groups[e[n]])})}),u})}var Rt={1:"base",2:"accent",3:"variant"};var Pt=Object.freeze({__proto__:null,$addFields:At,$set:Et,$bucket:function(n,u,t){var o=u.boundaries,i=u.default,a=o[0],s=o[o.length-1],r=u.output||{count:{$sum:1}};j(2<o.length,"$bucket 'boundaries' expression must have at least 3 elements");for(var e=M(a),c=0,f=o.length-1;c<f;c++)j(e===M(o[c+1]),"$bucket 'boundaries' must all be of the same type"),j(o[c]<o[c+1],"$bucket 'boundaries' must be sorted in ascending order");!V(i)&&M(u.default)===M(a)&&j(a>u.default||s<u.default,"$bucket 'default' expression must be out of boundaries range");var l={};Y(o,function(n){return l[n]=[]}),V(i)||(l[i]=[]);var v=!1;return Pn(function(){return v||(n.each(function(n){var t=Sn(n,u.groupBy);if(V(t)||t<a||s<=t)j(!V(i),"$bucket require a default for out of range values"),l[i].push(n);else{j(a<=t&&t<s,"$bucket 'groupBy' expression must resolve to a value in range of boundaries");var r=function(n,t){for(var r=0,e=n.length-1;r<=e;){var u=Math.round(r+(e-r)/2);if(t<n[u])e=u-1;else{if(!(t>n[u]))return u;r=u+1}}return r}(o,t),e=o[Math.max(0,r-1)];l[e].push(n)}}),o.pop(),V(i)||o.push(i),v=Pn(o).map(function(n){var t=Mn(l[n],null,r);return Object.assign(t,{_id:n})})),v.next()})},$bucketAuto:function(n,t,r){var d=t.output||{count:{$sum:1}},y=t.groupBy,g=t.buckets;return j(0<g,"The $bucketAuto 'buckets' field must be greater than 0, but found: "+g),n.transform(function(n){for(var t=Math.max(1,Math.round(n.length/g)),r=function(u){var o,i=this;return o={},function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];var e=un(t);return B(o,e)||(o[e]=u.apply(i,t)),o[e]}}(Sn),e={},u=[],o=an(n,function(n){var t=r(n,y);return V(t)?u.push(n):(e[t]||(e[t]=[]),e[t].push(n)),t}),i=An(),a=[],s=0,c=0,f=o.length;c<g&&s<f;c++){for(var l={},v=[],h=0;h<t&&s<f;h++){var p=r(o[s],y);V(p)&&(p=null),cn(v,V(p)?u:e[p]),s+=V(p)?u.length:e[p].length,B(l,"min")||(l.min=p),0<a.length&&(a[a.length-1][i].max=l.min)}c==g-1&&cn(v,o.slice(s)),a.push(Object.assign(Mn(v,null,d),{_id:l}))}return 0<a.length&&(a[a.length-1][i].max=r(o[o.length-1],y)),a})},$count:function(t,r,n){return j(R(r)&&""!==r.trim()&&-1===r.indexOf(".")&&"$"!==r.trim()[0],"Invalid expression value for $count"),Pn(function(){var n={};return n[r]=t.size(),{value:n,done:!1}}).first()},$facet:function(n,r,t){return n.transform(function(t){return[K(r,function(n){return zn(t,n)})]})},$group:Mt,$limit:function(n,t,r){return n.take(t)},$lookup:function(n,t,r){var e=t.from,u=t.localField,o=t.foreignField,i=t.as;j(I(e)&&R(o)&&R(u)&&R(i),"$lookup: invalid argument");var a={};return Y(e,function(n){var t=un(ln(n,o));a[t]=a[t]||[],a[t].push(n)}),n.map(function(n){var t=un(ln(n,u)),r=E(n);return r[i]=a[t]||[],r})},$match:function(n,t,r){var e=new Xn(t);return n.filter(function(n){return e.test(n)})},$out:function(n,t,r){return j(I(t),"$out expression must be an array"),n.map(function(n){return t.push(n),n})},$project:function(n,t,r){if(W(t))return n;var e=H(t),u=!1,o=An();if(St(t),D(e,o)){var i=t[o];0!==i&&!1!==i||(j(F(e=e.filter(F.bind(null,[o])),o),"Must not contain collections id key"),u=W(e))}else e.push(o);return n.map(function(n){return function s(c,f,n,t){var l=An(),v={},h=!1,p=!1,d=[];return t&&d.push(l),n.forEach(function(n){var t,r=f[n];if(n!==l&&D([0,!1],r)&&(p=!0),n===l&&W(r))t=c[n];else if(R(r))t=Sn(c,r,n);else if(D([1,!0],r));else if(I(r))t=r.map(function(n){var t=Sn(c,n);return V(t)?null:t});else{if(!C(r))return void d.push(n);var e=H(r),u=!(1<e.length)&&e[0];if(D(En(x),u)){var o=Gt[x];"$slice"===u?X(r[u]).every(P)?(t=o[u](c,r[u],n),h=!0):t=Sn(c,r,n):t=o[u](c,r[u],n)}else if(B(c,n)){St(r);var i=c[n];t=I(i)?i.map(function(n){return s(n,r,e,!1)}):s(i,r,e,!1)}else t=Sn(c,r,n)}var a=vn(c,n,{preserveMissingValues:!0});void 0!==a&&Q(v,a,{flatten:!0}),F([0,1,!1,!0],r)&&(void 0===t?yn(v,n):dn(v,n,t))}),hn(v),(h||p||t)&&(v=Object.assign({},c,v),0<d.length&&(v=A(v),Y(d,function(n){return yn(v,n)}))),v}(n,t,e,u)})},$redact:function(n,t,r){return n.map(function(n){return Nn(A(n),t)})},$replaceRoot:function(n,t,r){return n.map(function(n){return j(C(n=Sn(n,t.newRoot)),"$replaceRoot expression must return an object"),n})},$sample:function(n,t,r){var u=t.size;return j(P(u),"$sample size must be a positive integer"),n.transform(function(t){var r=t.length,e=-1;return function(){if(++e===u)return{done:!0};var n=Math.floor(Math.random()*r);return{value:t[n],done:!1}}})},$skip:function(n,t,r){return n.drop(t)},$sort:Nt,$sortByCount:function(n,t,r){var e={count:{$sum:1}};return e[An()]=t,Nt(Mt(n,e),{count:-1},r)},$unwind:function(u,n,t){R(n)&&(n={path:n});var o,i=n.path.substr(1),r=n.includeArrayIndex||!1,a=n.preserveNullAndEmptyArrays||!1,s=function(n,t){return!1!==r&&(n[r]=t),n};return Pn(function(){for(var n=function(){if(Pn.isIterator(o)){var n=o.next();if(!n.done)return{v:n}}var e=u.next();if(e.done)return{v:e};if(e=e.value,o=ln(e,i),I(o)){if(0===o.length&&!0===a){o=null;var t=A(e);return yn(t,i),{v:{value:s(t,null),done:!1}}}o=Pn(o).map(function(n,t){var r=A(e);return dn(r,i,n),s(r,t)})}else if(!W(o)||!0===a){var r=A(e);return{v:{value:s(r,null),done:!1}}}};;){var t=n();if("object"===e(t))return t.v}})}});var It=Object.freeze({__proto__:null,$:function(n,t,r){J("$ not implemented")},$elemMatch:function(n,t,r){var e=ln(n,r),u=new Xn(t);j(I(e),"$elemMatch: invalid argument");for(var o=0;o<e.length;o++)if(u.test(e[o]))return[e[o]]},$slice:function(n,t,r){var e=ln(n,r);return I(e)?I(t)?$n(e,t[0],t[1]):(j(P(t),"$slice: invalid arguments for projection"),$n(e,t)):e}});function Ct(u){return function(r,e){return function(n){var t=ln(n,r,{meta:!0});return t=function(n,t){if(t<1)return n;for(;t--&&I(n)&&1===n.length;)n=n[0];return n}(t.result,t.depth),u(t,e)}}}var Lt=Ct(function(n,t){var r=!1;if(I(n)&&I(t))for(var e=0,u=t.length;e<u;e++){if(!C(t[e])||!D(H(t[e]),"$elemMatch"))return G(t,n).length===u;r=r||nt(n,t[e].$elemMatch)}return r}),Tt=Ct(nt),qt=Ct(Bn),Vt=Ct(function(n,t){return(!1===t||0===t)&&void 0===n||(!0===t||1===t)&&void 0!==n}),Ut=Ct(Zn),Dt=Ct(Gn),Ft=Ct(Hn),zt=Ct(Kn),Wt=Ct(Qn),Xt=Ct(function(n,t){return X(n).some(function(n){return P(n)&&I(t)&&2===t.length&&n%t[0]===t[1]})}),Bt=Ct(Jn),Jt=Ct(Yn),Ht=Ct(function(n,t){var r=function(n){return R(n)&&!!n.match(t)};return(n=X(n)).some(r)||nn(n,1).some(r)}),Yt=Ct(function(n,t){return I(n)&&P(t)&&n.length===t}),Kt=Ct(function(n,t){switch(t){case 1:case"double":return P(n)&&-1!==(n+"").indexOf(".");case 2:case v:return R(n);case 3:case y:return C(n);case 4:case d:return I(n);case 6:case c:return V(n);case 8:case"bool":return N(n);case 9:case h:return T(n);case 10:case s:return U(n);case 11:case"regex":return q(n);case 16:case"int":return P(n)&&n<=2147483647&&-1===(n+"").indexOf(".");case 18:case"long":return P(n)&&2147483647<n&&n<=0x8000000000000000&&-1===(n+"").indexOf(".");case 19:case"decimal":return P(n);default:return!1}});function Qt(n,t){j(I(t),"Invalid expression. $or expects value to be an Array");var r=[];return Y(t,function(n){return r.push(new Xn(n))}),function(n){for(var t=0;t<r.length;t++)if(r[t].test(n))return!0;return!1}}var Zt=Object.freeze({__proto__:null,$all:Lt,$elemMatch:Tt,$eq:qt,$exists:Vt,$gt:Ut,$gte:Dt,$in:Ft,$lt:zt,$lte:Wt,$mod:Xt,$ne:Bt,$nin:Jt,$regex:Ht,$size:Yt,$type:Kt,$and:function(n,t){j(I(t),"Invalid expression: $and expects value to be an Array");var r=[];return Y(t,function(n){return r.push(new Xn(n))}),function(n){for(var t=0;t<r.length;t++)if(!r[t].test(n))return!1;return!0}},$or:Qt,$nor:function(n,t){j(I(t),"Invalid expression. $nor expects value to be an Array");var r=Qt(0,t);return function(n){return!r(n)}},$not:function(n,t){var r={};r[n]=mn(t);var e=new Xn(r);return function(n){return!e.test(n)}},$where:function(n,t){return r(t)||(t=new Function("return "+t+";")),function(n){return!0===t.call(n)}},$expr:function(n,t){return function(n){return Sn(n,t)}}}),Gt={};Gt[$]={},Gt[_]={},Gt[b]={},Gt[x]={},Gt[k]={};var nr={query:function(n,t){return new Xn(n).find(this.toJSON(),t)},aggregate:function(n){return new Fn(n).run(this.toJSON())}};Y([[$,Ot],[_,jt],[b,Pt],[x,It],[k,Zt]],function(n){var t=o(n,2),r=t[0],e=t[1];Object.assign(Gt[r],e)});return{_internal:bn,Aggregator:Fn,CollectionMixin:nr,Cursor:Wn,Lazy:Pn,OP_EXPRESSION:$,OP_GROUP:_,OP_PIPELINE:b,OP_PROJECTION:x,OP_QUERY:k,Query:Xn,VERSION:"2.5.3",addOperators:function(r,n){var a=n(bn());j(B(Gt,r),"Invalid operator class ".concat(r));var e=Gt[r];Y(a,function(n,t){j(/^\$[a-zA-Z0-9_]*$/.test(t),"Invalid operator name ".concat(t)),j(!B(e,t),"".concat(t," already exists for '").concat(r,"' operators"))});var t={};switch(r){case k:Y(a,function(o,i){o=o.bind(a),t[i]=function(e,u){return function(n){var t=ln(n,e),r=o(e,t,u);return j(N(r),"".concat(i," must return a boolean")),r}}});break;case x:Y(a,function(u,n){u=u.bind(a),t[n]=function(n,t,r){var e=ln(n,r);return u(r,e,t)}});break;default:Y(a,function(e,n){t[n]=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return e.apply(a,t)}})}Object.assign(Gt[r],t)},aggregate:zn,find:function(n,t,r){return new Xn(t).find(n,r)},remove:function(n,t){return new Xn(t).remove(n)},setup:function(n){Object.assign(xn,n||{})}}},"object"===(void 0===r?"undefined":_typeof2(r))&&void 0!==t?t.exports=u():"function"==typeof define&&define.amd?define(u):(e=e||self).mingo=u()},{}]},{},[1]); |
@@ -1,12 +0,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var extend = require("extend"); | ||
var extend = require("extend"), | ||
Mingo = require("mingo"); | ||
function instance(token) { | ||
var RX = new RegExp('\\' + token + '\\{[^\\}]+\\}', 'g'); // /\$\{[^\}]+\}/g; | ||
var RX_RPL_PARSE = new RegExp('\\' + token + '\\{([^\\}]+)\\}'); // /\$\{([^\}]+)\}/; | ||
var RX_RPL_TOKEN = new RegExp('\\' + token + '\\{|\\}', 'g'); // /\$\{|\}/g; | ||
var RX_JSON_TOKEN = new RegExp('^\\' + token + '\\{JSON(:(\\d+|([^:]+(:(\\d+))?)))?\\}$'); | ||
var RX = new RegExp("\\" + token + "\\{[^\\}]+\\}", 'g'); // /\$\{[^\}]+\}/g; | ||
var RX_RPL_PARSE = new RegExp("\\" + token + "\\{([^\\}]+)\\}"); // /\$\{([^\}]+)\}/; | ||
var RX_RPL_TOKEN = new RegExp("\\" + token + "\\{|\\}", 'g'); // /\$\{|\}/g; | ||
var RX_JSON_TOKEN = new RegExp("^\\" + token + "\\{JSON(:(\\d+|([^:]+(:(\\d+))?)))?\\}$"); | ||
var CACHE = {}; | ||
@@ -18,3 +19,3 @@ | ||
var rx = /^[a-zA-Z$_@]/; | ||
var fn = eval('(function(){\n\t\t\t\tlet rx = /^[a-zA-Z$_]/;\n\t\t\t\treturn \'' + rkey + '\'.startsWith(\'this.\') || \'' + rkey + '\'==\'this\' || !rx.test(\'' + rkey + '\')?\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=' + key + ';}\n\t\t\t\t\t\tcatch(err){}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t} :\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=this.' + (rx.test(key) ? key : '$___$') + ';}\n\t\t\t\t\t\tcatch(err){try{r=' + key + ';}catch(err){}}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t}\n\t\t\t})()'); | ||
var fn = eval("(function(){\n\t\t\t\tlet rx = /^[a-zA-Z$_]/;\n\t\t\t\treturn '" + rkey + "'.startsWith('this.') || '" + rkey + "'=='this' || !rx.test('" + rkey + "')?\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=" + key + ";}\n\t\t\t\t\t\tcatch(err){}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t} :\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tlet r = undefined;\n\t\t\t\t\t\ttry {r=this." + (rx.test(key) ? key : '$___$') + ";}\n\t\t\t\t\t\tcatch(err){try{r=" + key + ";}catch(err){}}\n\t\t\t\t\t\treturn r;\n\t\t\t\t\t}\n\t\t\t})()"); | ||
CACHE[key] = fn; | ||
@@ -34,3 +35,3 @@ } | ||
function fnassign(path) { | ||
return eval('(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj.' + path + ' = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()'); | ||
return eval("(function(){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\treturn obj." + path + " = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})()"); | ||
} | ||
@@ -59,3 +60,3 @@ | ||
for (var k in src) { | ||
var newpath = '' + path + (path ? '.' : '') + k; | ||
var newpath = "" + path + (path ? '.' : '') + k; | ||
var rop = ops[newpath]; | ||
@@ -152,3 +153,3 @@ if (rop !== undefined) src[k] = rop;else if (_typeof(src[k]) == "object") EVALS.valwalk(src[k], ops, newpath); | ||
Object.keys(json).forEach(function (k) { | ||
var newpath = '' + path + (path ? '.' : '') + k; | ||
var newpath = "" + path + (path ? '.' : '') + k; | ||
var t = json[k]; | ||
@@ -176,2 +177,12 @@ if (typeof t == "string") { | ||
function mingotokens(json) { | ||
var xpr = Array.isArray(json.$) ? json.$ : [json.$]; | ||
var aggr = new Mingo.Aggregator(xpr); | ||
return function (input) { | ||
var isArray = Array.isArray(input); | ||
var res = aggr.run(isArray ? input : [input]); | ||
if (!isArray && res.length <= 1) return res[0];else return res; | ||
}; | ||
} | ||
function exprfn(input, replace) { | ||
@@ -182,4 +193,18 @@ if (typeof input == 'number') { | ||
}; | ||
} else if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) == "object") { | ||
return jsontokens(input, replace); | ||
} else if ((typeof input === "undefined" ? "undefined" : _typeof(input)) == "object") { | ||
var ninput = extend({}, input); | ||
delete ninput['$']; | ||
var prfn = input["$"] ? mingotokens(input, replace) : function () { | ||
return input; | ||
}; | ||
var nxfn = Object.keys(ninput).length ? jsontokens(ninput, replace) : function (input) { | ||
return input; | ||
}; | ||
return function (input) { | ||
var prres = prfn(input); | ||
var nxres = nxfn(prres); | ||
if (typeof nxres._ !== 'undefined' && Object.keys(nxres).length == 1) return nxres._;else return nxres; | ||
}; | ||
} else { | ||
@@ -186,0 +211,0 @@ return tokens(input); |
'use strict'; | ||
var expression = require('./expression'); | ||
var expression = require('./expression'), | ||
mingo = require('./mingo_ex'); | ||
@@ -5,0 +6,0 @@ var instance = expression('$'); |
@@ -0,0 +0,0 @@ const expression = require('../../dist/node'); |
@@ -0,0 +0,0 @@ module.exports = function(grunt) { |
@@ -0,0 +0,0 @@ /*jshint esversion: 6 */ |
@@ -1,2 +0,4 @@ | ||
const extend = require("extend"); | ||
const | ||
extend = require("extend"), | ||
Mingo = require("mingo"); | ||
@@ -189,2 +191,13 @@ function instance(token) { | ||
function mingotokens(json) { | ||
let xpr = Array.isArray(json.$)? json.$ : [json.$]; | ||
let aggr = new Mingo.Aggregator(xpr); | ||
return function(input) { | ||
let isArray = Array.isArray(input); | ||
let res = aggr.run(isArray? input : [input]); | ||
if(!isArray && res.length<=1) return res[0]; | ||
else return res; | ||
} | ||
} | ||
function exprfn(input,replace){ | ||
@@ -195,3 +208,16 @@ if(typeof(input)=='number') { | ||
else if(typeof(input)=="object") { | ||
return jsontokens(input,replace); | ||
let ninput = extend({},input); | ||
delete ninput['$']; | ||
const prfn = input["$"] ? mingotokens(input, replace) : ()=>input; | ||
const nxfn = Object.keys(ninput).length? jsontokens(ninput,replace) : (input)=>input; | ||
return function(input) { | ||
let prres = prfn(input); | ||
let nxres = nxfn(prres); | ||
if(typeof(nxres._)!=='undefined' && Object.keys(nxres).length==1) | ||
return nxres._; | ||
else | ||
return nxres; | ||
} | ||
} | ||
@@ -198,0 +224,0 @@ else { |
@@ -1,2 +0,3 @@ | ||
let expression = require('./expression'); | ||
let expression = require('./expression'), | ||
mingo = require('./mingo_ex'); | ||
@@ -3,0 +4,0 @@ let instance = expression('$'); |
{ | ||
"name": "jsexpr", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "String and JSON expression interpolator and evaluator. Interpolates or evaluates a string against a json object, or transforms an object into another based on a json template", | ||
@@ -21,3 +21,4 @@ "main": "dist/node/index.js", | ||
"dependencies": { | ||
"extend": "^3.0.2" | ||
"extend": "^3.0.2", | ||
"mingo": "^2.3.5" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": { |
@@ -0,0 +0,0 @@ # jsexpr |
@@ -0,0 +0,0 @@ const expr = require('./index.js'); |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ const |
@@ -0,0 +0,0 @@ const |
@@ -0,0 +0,0 @@ const |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
553182
32
5741
2
19
+ Addedmingo@^2.3.5
+ Addedmingo@2.5.3(transitive)