Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marsdb

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marsdb - npm Package Compare versions

Comparing version 0.3.14 to 0.4.0

.babelrc

11

babelhook.js

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

require("babel/register")({
comments: true,
compact: false,
blacklist: [
'spec.functionName',
],
optional: [
'es7.trailingFunctionCommas',
]
});
require("babel-register")();

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

!function t(e,r,n){function o(c,s){if(!r[c]){if(!e[c]){var u="function"==typeof require&&require;if(!s&&u)return u(c,!0);if(i)return i(c,!0);var a=new Error("Cannot find module '"+c+"'");throw a.code="MODULE_NOT_FOUND",a}var f=r[c]={exports:{}};e[c][0].call(f.exports,function(t){var r=e[c][1][t];return o(r?r:t)},f,f.exports,t,e,r,n)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<n.length;c++)o(n[c]);return o}({1:[function(t,e,r){t("../modules/es6.object.to-string"),t("../modules/es6.string.iterator"),t("../modules/web.dom.iterable"),t("../modules/es6.promise"),e.exports=t("../modules/$.core").Promise},{"../modules/$.core":10,"../modules/es6.object.to-string":58,"../modules/es6.promise":59,"../modules/es6.string.iterator":61,"../modules/web.dom.iterable":63}],2:[function(t,e,r){t("../modules/es6.object.to-string"),t("../modules/es6.string.iterator"),t("../modules/web.dom.iterable"),t("../modules/es6.set"),e.exports=t("../modules/$.core").Set},{"../modules/$.core":10,"../modules/es6.object.to-string":58,"../modules/es6.set":60,"../modules/es6.string.iterator":61,"../modules/web.dom.iterable":63}],3:[function(t,e,r){t("../modules/es6.symbol"),e.exports=t("../modules/$.core").Symbol},{"../modules/$.core":10,"../modules/es6.symbol":62}],4:[function(t,e,r){e.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},{}],5:[function(t,e,r){var n=t("./$.is-object");e.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},{"./$.is-object":27}],6:[function(t,e,r){var n=t("./$.cof"),o=t("./$.wks")("toStringTag"),i="Arguments"==n(function(){return arguments}());e.exports=function(t){var e,r,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=(e=Object(t))[o])?r:i?n(e):"Object"==(c=n(e))&&"function"==typeof e.callee?"Arguments":c}},{"./$.cof":7,"./$.wks":55}],7:[function(t,e,r){var n={}.toString;e.exports=function(t){return n.call(t).slice(8,-1)}},{}],8:[function(t,e,r){"use strict";var n=t("./$"),o=t("./$.hide"),i=t("./$.ctx"),c=t("./$.species"),s=t("./$.strict-new"),u=t("./$.defined"),a=t("./$.for-of"),f=t("./$.iter-step"),l=t("./$.uid")("id"),$=t("./$.has"),p=t("./$.is-object"),d=Object.isExtensible||p,h=t("./$.support-desc"),v=h?"_s":"size",y=0,g=function(t,e){if(!p(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!$(t,l)){if(!d(t))return"F";if(!e)return"E";o(t,l,++y)}return"O"+t[l]},m=function(t,e){var r,n=g(e);if("F"!==n)return t._i[n];for(r=t._f;r;r=r.n)if(r.k==e)return r};e.exports={getConstructor:function(e,r,o,c){var f=e(function(t,e){s(t,f,r),t._i=n.create(null),t._f=void 0,t._l=void 0,t[v]=0,void 0!=e&&a(e,o,t[c],t)});return t("./$.mix")(f.prototype,{clear:function(){for(var t=this,e=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete e[r.i];t._f=t._l=void 0,t[v]=0},"delete":function(t){var e=this,r=m(e,t);if(r){var n=r.n,o=r.p;delete e._i[r.i],r.r=!0,o&&(o.n=n),n&&(n.p=o),e._f==r&&(e._f=n),e._l==r&&(e._l=o),e[v]--}return!!r},forEach:function(t){for(var e,r=i(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.n:this._f;)for(r(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!m(this,t)}}),h&&n.setDesc(f.prototype,"size",{get:function(){return u(this[v])}}),f},def:function(t,e,r){var n,o,i=m(t,e);return i?i.v=r:(t._l=i={i:o=g(e,!0),k:e,v:r,p:n=t._l,n:void 0,r:!1},t._f||(t._f=i),n&&(n.n=i),t[v]++,"F"!==o&&(t._i[o]=i)),t},getEntry:m,setStrong:function(e,r,n){t("./$.iter-define")(e,r,function(t,e){this._t=t,this._k=e,this._l=void 0},function(){for(var t=this,e=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==e?f(0,r.k):"values"==e?f(0,r.v):f(0,[r.k,r.v]):(t._t=void 0,f(1))},n?"entries":"values",!n,!0),c(e),c(t("./$.core")[r])}}},{"./$":34,"./$.core":10,"./$.ctx":11,"./$.defined":13,"./$.for-of":17,"./$.has":20,"./$.hide":21,"./$.is-object":27,"./$.iter-define":30,"./$.iter-step":32,"./$.mix":38,"./$.species":44,"./$.strict-new":45,"./$.support-desc":47,"./$.uid":53}],9:[function(t,e,r){"use strict";var n=t("./$.global"),o=t("./$.def"),i=t("./$.for-of"),c=t("./$.strict-new");e.exports=function(e,r,s,u,a,f){var l=n[e],$=l,p=a?"set":"add",d=$&&$.prototype,h={},v=function(e){var r=d[e];t("./$.redef")(d,e,"delete"==e?function(t){return r.call(this,0===t?0:t)}:"has"==e?function(t){return r.call(this,0===t?0:t)}:"get"==e?function(t){return r.call(this,0===t?0:t)}:"add"==e?function(t){return r.call(this,0===t?0:t),this}:function(t,e){return r.call(this,0===t?0:t,e),this})};if("function"==typeof $&&(f||d.forEach&&!t("./$.fails")(function(){(new $).entries().next()}))){var y,g=new $,m=g[p](f?{}:-0,1);t("./$.iter-detect")(function(t){new $(t)})||($=r(function(t,r){c(t,$,e);var n=new l;return void 0!=r&&i(r,a,n[p],n),n}),$.prototype=d,d.constructor=$),f||g.forEach(function(t,e){y=1/e===-(1/0)}),y&&(v("delete"),v("has"),a&&v("get")),(y||m!==g)&&v(p),f&&d.clear&&delete d.clear}else $=u.getConstructor(r,e,a,p),t("./$.mix")($.prototype,s);return t("./$.tag")($,e),h[e]=$,o(o.G+o.W+o.F*($!=l),h),f||u.setStrong($,e,a),$}},{"./$.def":12,"./$.fails":16,"./$.for-of":17,"./$.global":19,"./$.iter-detect":31,"./$.mix":38,"./$.redef":40,"./$.strict-new":45,"./$.tag":48}],10:[function(t,e,r){var n=e.exports={version:"1.2.2"};"number"==typeof __e&&(__e=n)},{}],11:[function(t,e,r){var n=t("./$.a-function");e.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},{"./$.a-function":4}],12:[function(t,e,r){var n=t("./$.global"),o=t("./$.core"),i=t("./$.hide"),c=t("./$.redef"),s="prototype",u=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e,r){var f,l,$,p,d=t&a.G,h=t&a.P,v=d?n:t&a.S?n[e]||(n[e]={}):(n[e]||{})[s],y=d?o:o[e]||(o[e]={});d&&(r=e);for(f in r)l=!(t&a.F)&&v&&f in v,$=(l?v:r)[f],p=t&a.B&&l?u($,n):h&&"function"==typeof $?u(Function.call,$):$,v&&!l&&c(v,f,$),y[f]!=$&&i(y,f,p),h&&((y[s]||(y[s]={}))[f]=$)};n.core=o,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,e.exports=a},{"./$.core":10,"./$.global":19,"./$.hide":21,"./$.redef":40}],13:[function(t,e,r){e.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},{}],14:[function(t,e,r){var n=t("./$.is-object"),o=t("./$.global").document,i=n(o)&&n(o.createElement);e.exports=function(t){return i?o.createElement(t):{}}},{"./$.global":19,"./$.is-object":27}],15:[function(t,e,r){var n=t("./$");e.exports=function(t){var e=n.getKeys(t),r=n.getSymbols;if(r)for(var o,i=r(t),c=n.isEnum,s=0;i.length>s;)c.call(t,o=i[s++])&&e.push(o);return e}},{"./$":34}],16:[function(t,e,r){e.exports=function(t){try{return!!t()}catch(e){return!0}}},{}],17:[function(t,e,r){var n=t("./$.ctx"),o=t("./$.iter-call"),i=t("./$.is-array-iter"),c=t("./$.an-object"),s=t("./$.to-length"),u=t("./core.get-iterator-method");e.exports=function(t,e,r,a){var f,l,$,p=u(t),d=n(r,a,e?2:1),h=0;if("function"!=typeof p)throw TypeError(t+" is not iterable!");if(i(p))for(f=s(t.length);f>h;h++)e?d(c(l=t[h])[0],l[1]):d(t[h]);else for($=p.call(t);!(l=$.next()).done;)o($,d,l.value,e)}},{"./$.an-object":5,"./$.ctx":11,"./$.is-array-iter":25,"./$.iter-call":28,"./$.to-length":52,"./core.get-iterator-method":56}],18:[function(t,e,r){var n={}.toString,o=t("./$.to-iobject"),i=t("./$").getNames,c="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(t){try{return i(t)}catch(e){return c.slice()}};e.exports.get=function(t){return c&&"[object Window]"==n.call(t)?s(t):i(o(t))}},{"./$":34,"./$.to-iobject":51}],19:[function(t,e,r){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},{}],20:[function(t,e,r){var n={}.hasOwnProperty;e.exports=function(t,e){return n.call(t,e)}},{}],21:[function(t,e,r){var n=t("./$"),o=t("./$.property-desc");e.exports=t("./$.support-desc")?function(t,e,r){return n.setDesc(t,e,o(1,r))}:function(t,e,r){return t[e]=r,t}},{"./$":34,"./$.property-desc":39,"./$.support-desc":47}],22:[function(t,e,r){e.exports=t("./$.global").document&&document.documentElement},{"./$.global":19}],23:[function(t,e,r){e.exports=function(t,e,r){var n=void 0===r;switch(e.length){case 0:return n?t():t.call(r);case 1:return n?t(e[0]):t.call(r,e[0]);case 2:return n?t(e[0],e[1]):t.call(r,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(r,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(r,e[0],e[1],e[2],e[3])}return t.apply(r,e)}},{}],24:[function(t,e,r){var n=t("./$.cof");e.exports=0 in Object("z")?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},{"./$.cof":7}],25:[function(t,e,r){var n=t("./$.iterators"),o=t("./$.wks")("iterator");e.exports=function(t){return(n.Array||Array.prototype[o])===t}},{"./$.iterators":33,"./$.wks":55}],26:[function(t,e,r){var n=t("./$.cof");e.exports=Array.isArray||function(t){return"Array"==n(t)}},{"./$.cof":7}],27:[function(t,e,r){e.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},{}],28:[function(t,e,r){var n=t("./$.an-object");e.exports=function(t,e,r,o){try{return o?e(n(r)[0],r[1]):e(r)}catch(i){var c=t["return"];throw void 0!==c&&n(c.call(t)),i}}},{"./$.an-object":5}],29:[function(t,e,r){"use strict";var n=t("./$"),o={};t("./$.hide")(o,t("./$.wks")("iterator"),function(){return this}),e.exports=function(e,r,i){e.prototype=n.create(o,{next:t("./$.property-desc")(1,i)}),t("./$.tag")(e,r+" Iterator")}},{"./$":34,"./$.hide":21,"./$.property-desc":39,"./$.tag":48,"./$.wks":55}],30:[function(t,e,r){"use strict";var n=t("./$.library"),o=t("./$.def"),i=t("./$.redef"),c=t("./$.hide"),s=t("./$.has"),u=t("./$.wks")("iterator"),a=t("./$.iterators"),f=!([].keys&&"next"in[].keys()),l="@@iterator",$="keys",p="values",d=function(){return this};e.exports=function(e,r,h,v,y,g,m){t("./$.iter-create")(h,r,v);var b,w,x=function(t){switch(t){case $:return function(){return new h(this,t)};case p:return function(){return new h(this,t)}}return function(){return new h(this,t)}},j=r+" Iterator",_=e.prototype,k=_[u]||_[l]||y&&_[y],S=k||x(y);if(k){var O=t("./$").getProto(S.call(new e));t("./$.tag")(O,j,!0),!n&&s(_,l)&&c(O,u,d)}if((!n||m)&&c(_,u,S),a[r]=S,a[j]=d,y)if(b={keys:g?S:x($),values:y==p?S:x(p),entries:y!=p?S:x("entries")},m)for(w in b)w in _||i(_,w,b[w]);else o(o.P+o.F*f,r,b)}},{"./$":34,"./$.def":12,"./$.has":20,"./$.hide":21,"./$.iter-create":29,"./$.iterators":33,"./$.library":36,"./$.redef":40,"./$.tag":48,"./$.wks":55}],31:[function(t,e,r){var n=t("./$.wks")("iterator"),o=!1;try{var i=[7][n]();i["return"]=function(){o=!0},Array.from(i,function(){throw 2})}catch(c){}e.exports=function(t,e){if(!e&&!o)return!1;var r=!1;try{var i=[7],c=i[n]();c.next=function(){r=!0},i[n]=function(){return c},t(i)}catch(s){}return r}},{"./$.wks":55}],32:[function(t,e,r){e.exports=function(t,e){return{value:e,done:!!t}}},{}],33:[function(t,e,r){e.exports={}},{}],34:[function(t,e,r){var n=Object;e.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},{}],35:[function(t,e,r){var n=t("./$"),o=t("./$.to-iobject");e.exports=function(t,e){for(var r,i=o(t),c=n.getKeys(i),s=c.length,u=0;s>u;)if(i[r=c[u++]]===e)return r}},{"./$":34,"./$.to-iobject":51}],36:[function(t,e,r){e.exports=!1},{}],37:[function(t,e,r){var n,o,i,c=t("./$.global"),s=t("./$.task").set,u=c.MutationObserver||c.WebKitMutationObserver,a=c.process,f="process"==t("./$.cof")(a),l=function(){var t,e;for(f&&(t=a.domain)&&(a.domain=null,t.exit());n;)e=n.domain,e&&e.enter(),n.fn.call(),e&&e.exit(),n=n.next;o=void 0,t&&t.enter()};if(f)i=function(){a.nextTick(l)};else if(u){var $=1,p=document.createTextNode("");new u(l).observe(p,{characterData:!0}),i=function(){p.data=$=-$}}else i=function(){s.call(c,l)};e.exports=function(t){var e={fn:t,next:void 0,domain:f&&a.domain};o&&(o.next=e),n||(n=e,i()),o=e}},{"./$.cof":7,"./$.global":19,"./$.task":49}],38:[function(t,e,r){var n=t("./$.redef");e.exports=function(t,e){for(var r in e)n(t,r,e[r]);return t}},{"./$.redef":40}],39:[function(t,e,r){e.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},{}],40:[function(t,e,r){var n=t("./$.global"),o=t("./$.hide"),i=t("./$.uid")("src"),c="toString",s=Function[c],u=(""+s).split(c);t("./$.core").inspectSource=function(t){return s.call(t)},(e.exports=function(t,e,r,c){"function"==typeof r&&(o(r,i,t[e]?""+t[e]:u.join(String(e))),"name"in r||(r.name=e)),t===n?t[e]=r:(c||delete t[e],o(t,e,r))})(Function.prototype,c,function(){return"function"==typeof this&&this[i]||s.call(this)})},{"./$.core":10,"./$.global":19,"./$.hide":21,"./$.uid":53}],41:[function(t,e,r){e.exports=Object.is||function(t,e){return t===e?0!==t||1/t===1/e:t!=t&&e!=e}},{}],42:[function(t,e,r){var n=t("./$").getDesc,o=t("./$.is-object"),i=t("./$.an-object"),c=function(t,e){if(i(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,r,o){try{o=t("./$.ctx")(Function.call,n(Object.prototype,"__proto__").set,2),o(e,[]),r=!(e instanceof Array)}catch(i){r=!0}return function(t,e){return c(t,e),r?t.__proto__=e:o(t,e),t}}({},!1):void 0),check:c}},{"./$":34,"./$.an-object":5,"./$.ctx":11,"./$.is-object":27}],43:[function(t,e,r){var n=t("./$.global"),o="__core-js_shared__",i=n[o]||(n[o]={});e.exports=function(t){return i[t]||(i[t]={})}},{"./$.global":19}],44:[function(t,e,r){"use strict";var n=t("./$"),o=t("./$.wks")("species");e.exports=function(e){!t("./$.support-desc")||o in e||n.setDesc(e,o,{configurable:!0,get:function(){return this}})}},{"./$":34,"./$.support-desc":47,"./$.wks":55}],45:[function(t,e,r){e.exports=function(t,e,r){if(!(t instanceof e))throw TypeError(r+": use the 'new' operator!");return t}},{}],46:[function(t,e,r){var n=t("./$.to-integer"),o=t("./$.defined");e.exports=function(t){return function(e,r){var i,c,s=String(o(e)),u=n(r),a=s.length;return 0>u||u>=a?t?"":void 0:(i=s.charCodeAt(u),55296>i||i>56319||u+1===a||(c=s.charCodeAt(u+1))<56320||c>57343?t?s.charAt(u):i:t?s.slice(u,u+2):(i-55296<<10)+(c-56320)+65536)}}},{"./$.defined":13,"./$.to-integer":50}],47:[function(t,e,r){e.exports=!t("./$.fails")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{"./$.fails":16}],48:[function(t,e,r){var n=t("./$").setDesc,o=t("./$.has"),i=t("./$.wks")("toStringTag");e.exports=function(t,e,r){t&&!o(t=r?t:t.prototype,i)&&n(t,i,{configurable:!0,value:e})}},{"./$":34,"./$.has":20,"./$.wks":55}],49:[function(t,e,r){"use strict";var n,o,i,c=t("./$.ctx"),s=t("./$.invoke"),u=t("./$.html"),a=t("./$.dom-create"),f=t("./$.global"),l=f.process,$=f.setImmediate,p=f.clearImmediate,d=f.MessageChannel,h=0,v={},y="onreadystatechange",g=function(){var t=+this;if(v.hasOwnProperty(t)){var e=v[t];delete v[t],e()}},m=function(t){g.call(t.data)};$&&p||($=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return v[++h]=function(){s("function"==typeof t?t:Function(t),e)},n(h),h},p=function(t){delete v[t]},"process"==t("./$.cof")(l)?n=function(t){l.nextTick(c(g,t,1))}:d?(o=new d,i=o.port2,o.port1.onmessage=m,n=c(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(n=function(t){f.postMessage(t+"","*")},f.addEventListener("message",m,!1)):n=y in a("script")?function(t){u.appendChild(a("script"))[y]=function(){u.removeChild(this),g.call(t)}}:function(t){setTimeout(c(g,t,1),0)}),e.exports={set:$,clear:p}},{"./$.cof":7,"./$.ctx":11,"./$.dom-create":14,"./$.global":19,"./$.html":22,"./$.invoke":23}],50:[function(t,e,r){var n=Math.ceil,o=Math.floor;e.exports=function(t){return isNaN(t=+t)?0:(t>0?o:n)(t)}},{}],51:[function(t,e,r){var n=t("./$.iobject"),o=t("./$.defined");e.exports=function(t){return n(o(t))}},{"./$.defined":13,"./$.iobject":24}],52:[function(t,e,r){var n=t("./$.to-integer"),o=Math.min;e.exports=function(t){return t>0?o(n(t),9007199254740991):0}},{"./$.to-integer":50}],53:[function(t,e,r){var n=0,o=Math.random();e.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+o).toString(36))}},{}],54:[function(t,e,r){var n=t("./$.wks")("unscopables");void 0==[][n]&&t("./$.hide")(Array.prototype,n,{}),e.exports=function(t){[][n][t]=!0}},{"./$.hide":21,"./$.wks":55}],55:[function(t,e,r){var n=t("./$.shared")("wks"),o=t("./$.global").Symbol;e.exports=function(e){return n[e]||(n[e]=o&&o[e]||(o||t("./$.uid"))("Symbol."+e))}},{"./$.global":19,"./$.shared":43,"./$.uid":53}],56:[function(t,e,r){var n=t("./$.classof"),o=t("./$.wks")("iterator"),i=t("./$.iterators");e.exports=t("./$.core").getIteratorMethod=function(t){return void 0!=t?t[o]||t["@@iterator"]||i[n(t)]:void 0}},{"./$.classof":6,"./$.core":10,"./$.iterators":33,"./$.wks":55}],57:[function(t,e,r){"use strict";var n=t("./$.unscope"),o=t("./$.iter-step"),i=t("./$.iterators"),c=t("./$.to-iobject");t("./$.iter-define")(Array,"Array",function(t,e){this._t=c(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):"keys"==e?o(0,r):"values"==e?o(0,t[r]):o(0,[r,t[r]])},"values"),i.Arguments=i.Array,n("keys"),n("values"),n("entries")},{"./$.iter-define":30,"./$.iter-step":32,"./$.iterators":33,"./$.to-iobject":51,"./$.unscope":54}],58:[function(t,e,r){"use strict";var n=t("./$.classof"),o={};o[t("./$.wks")("toStringTag")]="z",o+""!="[object z]"&&t("./$.redef")(Object.prototype,"toString",function(){return"[object "+n(this)+"]"},!0)},{"./$.classof":6,"./$.redef":40,"./$.wks":55}],59:[function(t,e,r){"use strict";var n,o=t("./$"),i=t("./$.library"),c=t("./$.global"),s=t("./$.ctx"),u=t("./$.classof"),a=t("./$.def"),f=t("./$.is-object"),l=t("./$.an-object"),$=t("./$.a-function"),p=t("./$.strict-new"),d=t("./$.for-of"),h=t("./$.set-proto").set,v=t("./$.same"),y=t("./$.species"),g=t("./$.wks")("species"),m=t("./$.uid")("record"),b=t("./$.microtask"),w="Promise",x=c.process,j="process"==u(x),_=c[w],k=function(t){var e=new _(function(){});return t&&(e.constructor=Object),_.resolve(e)===e},S=function(){function e(t){var r=new _(t);return h(r,e.prototype),r}var r=!1;try{if(r=_&&_.resolve&&k(),h(e,_),e.prototype=o.create(_.prototype,{constructor:{value:e}}),e.resolve(5).then(function(){})instanceof e||(r=!1),r&&t("./$.support-desc")){var n=!1;_.resolve(o.setDesc({},"then",{get:function(){n=!0}})),r=n}}catch(i){r=!1}return r}(),O=function(t){return f(t)&&(S?"Promise"==u(t):m in t)},P=function(t,e){return i&&t===_&&e===n?!0:v(t,e)},E=function(t){var e=l(t)[g];return void 0!=e?e:t},F=function(t){var e;return f(t)&&"function"==typeof(e=t.then)?e:!1},M=function(t,e){if(!t.n){t.n=!0;var r=t.c;b(function(){for(var n=t.v,o=1==t.s,i=0,s=function(e){var r,i,c=o?e.ok:e.fail;try{c?(o||(t.h=!0),r=c===!0?n:c(n),r===e.P?e.rej(TypeError("Promise-chain cycle")):(i=F(r))?i.call(r,e.res,e.rej):e.res(r)):e.rej(n)}catch(s){e.rej(s)}};r.length>i;)s(r[i++]);r.length=0,t.n=!1,e&&setTimeout(function(){var e,r,o=t.p;T(o)&&(j?x.emit("unhandledRejection",n,o):(e=c.onunhandledrejection)?e({promise:o,reason:n}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",n)),t.a=void 0},1)})}},T=function(t){var e,r=t[m],n=r.a||r.c,o=0;if(r.h)return!1;for(;n.length>o;)if(e=n[o++],e.fail||!T(e.P))return!1;return!0},A=function(t){var e=this;e.d||(e.d=!0,e=e.r||e,e.v=t,e.s=2,e.a=e.c.slice(),M(e,!0))},D=function(t){var e,r=this;if(!r.d){r.d=!0,r=r.r||r;try{(e=F(t))?b(function(){var n={r:r,d:!1};try{e.call(t,s(D,n,1),s(A,n,1))}catch(o){A.call(n,o)}}):(r.v=t,r.s=1,M(r,!1))}catch(n){A.call({r:r,d:!1},n)}}};S||(_=function(t){$(t);var e={p:p(this,_,w),c:[],a:void 0,s:0,d:!1,v:void 0,h:!1,n:!1};this[m]=e;try{t(s(D,e,1),s(A,e,1))}catch(r){A.call(e,r)}},t("./$.mix")(_.prototype,{then:function(t,e){var r=l(l(this).constructor)[g],n={ok:"function"==typeof t?t:!0,fail:"function"==typeof e?e:!1},o=n.P=new(void 0!=r?r:_)(function(t,e){n.res=t,n.rej=e});$(n.res),$(n.rej);var i=this[m];return i.c.push(n),i.a&&i.a.push(n),i.s&&M(i,!1),o},"catch":function(t){return this.then(void 0,t)}})),a(a.G+a.W+a.F*!S,{Promise:_}),t("./$.tag")(_,w),y(_),y(n=t("./$.core")[w]),a(a.S+a.F*!S,w,{reject:function(t){return new this(function(e,r){r(t)})}}),a(a.S+a.F*(!S||k(!0)),w,{resolve:function(t){return O(t)&&P(t.constructor,this)?t:new this(function(e){e(t)})}}),a(a.S+a.F*!(S&&t("./$.iter-detect")(function(t){_.all(t)["catch"](function(){})})),w,{all:function(t){var e=E(this),r=[];return new e(function(n,i){d(t,!1,r.push,r);var c=r.length,s=Array(c);c?o.each.call(r,function(t,r){e.resolve(t).then(function(t){s[r]=t,--c||n(s)},i)}):n(s)})},race:function(t){var e=E(this);return new e(function(r,n){d(t,!1,function(t){e.resolve(t).then(r,n)})})}})},{"./$":34,"./$.a-function":4,"./$.an-object":5,"./$.classof":6,"./$.core":10,"./$.ctx":11,"./$.def":12,"./$.for-of":17,"./$.global":19,"./$.is-object":27,"./$.iter-detect":31,"./$.library":36,"./$.microtask":37,"./$.mix":38,"./$.same":41,"./$.set-proto":42,"./$.species":44,"./$.strict-new":45,"./$.support-desc":47,"./$.tag":48,"./$.uid":53,"./$.wks":55}],60:[function(t,e,r){"use strict";var n=t("./$.collection-strong");t("./$.collection")("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return n.def(this,t=0===t?0:t,t)}},n)},{"./$.collection":9,"./$.collection-strong":8}],61:[function(t,e,r){"use strict";var n=t("./$.string-at")(!0);t("./$.iter-define")(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,r=this._i;return r>=e.length?{value:void 0,done:!0}:(t=n(e,r),this._i+=t.length,{value:t,done:!1})})},{"./$.iter-define":30,"./$.string-at":46}],62:[function(t,e,r){"use strict";var n=t("./$"),o=t("./$.global"),i=t("./$.has"),c=t("./$.support-desc"),s=t("./$.def"),u=t("./$.redef"),a=t("./$.fails"),f=t("./$.shared"),l=t("./$.tag"),$=t("./$.uid"),p=t("./$.wks"),d=t("./$.keyof"),h=t("./$.get-names"),v=t("./$.enum-keys"),y=t("./$.is-array"),g=t("./$.an-object"),m=t("./$.to-iobject"),b=t("./$.property-desc"),w=n.getDesc,x=n.setDesc,j=n.create,_=h.get,k=o.Symbol,S=o.JSON,O=S&&S.stringify,P=!1,E=p("_hidden"),F=n.isEnum,M=f("symbol-registry"),T=f("symbols"),A="function"==typeof k,D=Object.prototype,N=c&&a(function(){return 7!=j(x({},"a",{get:function(){return x(this,"a",{value:7}).a}})).a})?function(t,e,r){var n=w(D,e);n&&delete D[e],x(t,e,r),n&&t!==D&&x(D,e,n)}:x,C=function(t){var e=T[t]=j(k.prototype);return e._k=t,c&&P&&N(D,t,{configurable:!0,set:function(e){i(this,E)&&i(this[E],t)&&(this[E][t]=!1),N(this,t,b(1,e))}}),e},I=function(t){return"symbol"==typeof t},L=function(t,e,r){return r&&i(T,e)?(r.enumerable?(i(t,E)&&t[E][e]&&(t[E][e]=!1),r=j(r,{enumerable:b(0,!1)})):(i(t,E)||x(t,E,b(1,{})),t[E][e]=!0),N(t,e,r)):x(t,e,r)},W=function(t,e){g(t);for(var r,n=v(e=m(e)),o=0,i=n.length;i>o;)L(t,r=n[o++],e[r]);return t},z=function(t,e){return void 0===e?j(t):W(j(t),e)},G=function(t){var e=F.call(this,t);return e||!i(this,t)||!i(T,t)||i(this,E)&&this[E][t]?e:!0},q=function(t,e){var r=w(t=m(t),e);return!r||!i(T,e)||i(t,E)&&t[E][e]||(r.enumerable=!0),r},J=function(t){for(var e,r=_(m(t)),n=[],o=0;r.length>o;)i(T,e=r[o++])||e==E||n.push(e);return n},K=function(t){for(var e,r=_(m(t)),n=[],o=0;r.length>o;)i(T,e=r[o++])&&n.push(T[e]);return n},U=function(t){for(var e,r,n=[t],o=1,i=arguments;i.length>o;)n.push(i[o++]);return e=n[1],"function"==typeof e&&(r=e),(r||!y(e))&&(e=function(t,e){return r&&(e=r.call(this,t,e)),I(e)?void 0:e}),n[1]=e,O.apply(S,n)},B=a(function(){var t=k();return"[null]"!=O([t])||"{}"!=O({a:t})||"{}"!=O(Object(t))});A||(k=function(){if(I(this))throw TypeError("Symbol is not a constructor");return C($(arguments.length>0?arguments[0]:void 0))},u(k.prototype,"toString",function(){return this._k}),I=function(t){return t instanceof k},n.create=z,n.isEnum=G,n.getDesc=q,n.setDesc=L,n.setDescs=W,n.getNames=h.get=J,n.getSymbols=K,c&&!t("./$.library")&&u(D,"propertyIsEnumerable",G,!0));var H={"for":function(t){return i(M,t+="")?M[t]:M[t]=k(t)},keyFor:function(t){return d(M,t)},useSetter:function(){P=!0},useSimple:function(){P=!1}};n.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(t){var e=p(t);H[t]=A?e:C(e)}),P=!0,s(s.G+s.W,{Symbol:k}),s(s.S,"Symbol",H),s(s.S+s.F*!A,"Object",{create:z,defineProperty:L,defineProperties:W,getOwnPropertyDescriptor:q,getOwnPropertyNames:J,getOwnPropertySymbols:K}),S&&s(s.S+s.F*(!A||B),"JSON",{stringify:U}),l(k,"Symbol"),l(Math,"Math",!0),l(o.JSON,"JSON",!0)},{"./$":34,"./$.an-object":5,"./$.def":12,"./$.enum-keys":15,"./$.fails":16,"./$.get-names":18,"./$.global":19,"./$.has":20,"./$.is-array":26,"./$.keyof":35,"./$.library":36,"./$.property-desc":39,"./$.redef":40,"./$.shared":43,"./$.support-desc":47,"./$.tag":48,"./$.to-iobject":51,"./$.uid":53,"./$.wks":55}],63:[function(t,e,r){t("./es6.array.iterator");var n=t("./$.global"),o=t("./$.hide"),i=t("./$.iterators"),c=t("./$.wks")("iterator"),s=n.NodeList,u=n.HTMLCollection,a=s&&s.prototype,f=u&&u.prototype,l=i.NodeList=i.HTMLCollection=i.Array;!s||c in a||o(a,c,l),!u||c in f||o(f,c,l)},{"./$.global":19,"./$.hide":21,"./$.iterators":33,"./$.wks":55,"./es6.array.iterator":57}],64:[function(t,e,r){(function(e){"undefined"!=typeof window?(window.Symbol=t("core-js/es6/symbol"),window.Promise=t("core-js/es6/promise"),window.Set=t("core-js/es6/set")):(e.Symbol=t("core-js/es6/symbol"),e.Promise=t("core-js/es6/promise"),e.Set=t("core-js/es6/set"))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"core-js/es6/promise":1,"core-js/es6/set":2,"core-js/es6/symbol":3}]},{},[64]);
!function t(e,r,n){function o(s,c){if(!r[s]){if(!e[s]){var a="function"==typeof require&&require;if(!c&&a)return a(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return o(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e,r){t("../modules/es6.object.to-string"),t("../modules/es6.string.iterator"),t("../modules/web.dom.iterable"),t("../modules/es6.promise"),e.exports=t("../modules/_core").Promise},{"../modules/_core":13,"../modules/es6.object.to-string":59,"../modules/es6.promise":60,"../modules/es6.string.iterator":62,"../modules/web.dom.iterable":64}],2:[function(t,e,r){t("../modules/es6.object.to-string"),t("../modules/es6.string.iterator"),t("../modules/web.dom.iterable"),t("../modules/es6.set"),e.exports=t("../modules/_core").Set},{"../modules/_core":13,"../modules/es6.object.to-string":59,"../modules/es6.set":61,"../modules/es6.string.iterator":62,"../modules/web.dom.iterable":64}],3:[function(t,e,r){t("../modules/es6.symbol"),t("../modules/es6.object.to-string"),e.exports=t("../modules/_core").Symbol},{"../modules/_core":13,"../modules/es6.object.to-string":59,"../modules/es6.symbol":63}],4:[function(t,e,r){var n=Object;e.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},{}],5:[function(t,e,r){e.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},{}],6:[function(t,e,r){var n=t("./_wks")("unscopables"),o=Array.prototype;void 0==o[n]&&t("./_hide")(o,n,{}),e.exports=function(t){o[n][t]=!0}},{"./_hide":25,"./_wks":56}],7:[function(t,e,r){e.exports=function(t,e,r,n){if(!(t instanceof e)||void 0!==n&&n in t)throw TypeError(r+": incorrect invocation!");return t}},{}],8:[function(t,e,r){var n=t("./_is-object");e.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},{"./_is-object":31}],9:[function(t,e,r){var n=t("./_cof"),o=t("./_wks")("toStringTag"),i="Arguments"==n(function(){return arguments}());e.exports=function(t){var e,r,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=(e=Object(t))[o])?r:i?n(e):"Object"==(s=n(e))&&"function"==typeof e.callee?"Arguments":s}},{"./_cof":10,"./_wks":56}],10:[function(t,e,r){var n={}.toString;e.exports=function(t){return n.call(t).slice(8,-1)}},{}],11:[function(t,e,r){"use strict";var n=t("./_"),o=(t("./_hide"),t("./_redefine-all")),i=t("./_ctx"),s=t("./_an-instance"),c=t("./_defined"),a=t("./_for-of"),u=t("./_iter-define"),f=t("./_iter-step"),_=t("./_set-species"),l=t("./_descriptors"),p=t("./_meta").fastKey,d=l?"_s":"size",h=function(t,e){var r,n=p(e);if("F"!==n)return t._i[n];for(r=t._f;r;r=r.n)if(r.k==e)return r};e.exports={getConstructor:function(t,e,r,u){var f=t(function(t,o){s(t,f,e,"_i"),t._i=n.create(null),t._f=void 0,t._l=void 0,t[d]=0,void 0!=o&&a(o,r,t[u],t)});return o(f.prototype,{clear:function(){for(var t=this,e=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete e[r.i];t._f=t._l=void 0,t[d]=0},"delete":function(t){var e=this,r=h(e,t);if(r){var n=r.n,o=r.p;delete e._i[r.i],r.r=!0,o&&(o.n=n),n&&(n.p=o),e._f==r&&(e._f=n),e._l==r&&(e._l=o),e[d]--}return!!r},forEach:function(t){s(this,f,"forEach");for(var e,r=i(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.n:this._f;)for(r(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!h(this,t)}}),l&&n.setDesc(f.prototype,"size",{get:function(){return c(this[d])}}),f},def:function(t,e,r){var n,o,i=h(t,e);return i?i.v=r:(t._l=i={i:o=p(e,!0),k:e,v:r,p:n=t._l,n:void 0,r:!1},t._f||(t._f=i),n&&(n.n=i),t[d]++,"F"!==o&&(t._i[o]=i)),t},getEntry:h,setStrong:function(t,e,r){u(t,e,function(t,e){this._t=t,this._k=e,this._l=void 0},function(){for(var t=this,e=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==e?f(0,r.k):"values"==e?f(0,r.v):f(0,[r.k,r.v]):(t._t=void 0,f(1))},r?"entries":"values",!r,!0),_(e)}}},{"./_":4,"./_an-instance":7,"./_ctx":14,"./_defined":15,"./_descriptors":16,"./_for-of":21,"./_hide":25,"./_iter-define":34,"./_iter-step":36,"./_meta":40,"./_redefine-all":43,"./_set-species":46}],12:[function(t,e,r){"use strict";var n=t("./_global"),o=t("./_export"),i=t("./_redefine"),s=t("./_redefine-all"),c=t("./_meta"),a=t("./_for-of"),u=t("./_an-instance"),f=t("./_is-object"),_=t("./_fails"),l=t("./_iter-detect"),p=t("./_set-to-string-tag");e.exports=function(t,e,r,d,h,v){var g=n[t],y=g,m=h?"set":"add",b=y&&y.prototype,w={},x=function(t){var e=b[t];i(b,t,"delete"==t?function(t){return v&&!f(t)?!1:e.call(this,0===t?0:t)}:"has"==t?function(t){return v&&!f(t)?!1:e.call(this,0===t?0:t)}:"get"==t?function(t){return v&&!f(t)?void 0:e.call(this,0===t?0:t)}:"add"==t?function(t){return e.call(this,0===t?0:t),this}:function(t,r){return e.call(this,0===t?0:t,r),this})};if("function"==typeof y&&(v||b.forEach&&!_(function(){(new y).entries().next()}))){var j=new y,k=j[m](v?{}:-0,1)!=j,S=_(function(){j.has(1)}),O=l(function(t){new y(t)}),E=!v&&_(function(){for(var t=new y,e=5;e--;)t[m](e,e);return!t.has(-0)});O||(y=e(function(e,r){u(e,y,t);var n=new g;return void 0!=r&&a(r,h,n[m],n),n}),y.prototype=b,b.constructor=y),(S||E)&&(x("delete"),x("has"),h&&x("get")),(E||k)&&x(m),v&&b.clear&&delete b.clear}else y=d.getConstructor(e,t,h,m),s(y.prototype,r),c.NEED=!0;return p(y,t),w[t]=y,o(o.G+o.W+o.F*(y!=g),w),v||d.setStrong(y,t,h),y}},{"./_an-instance":7,"./_export":19,"./_fails":20,"./_for-of":21,"./_global":23,"./_is-object":31,"./_iter-detect":35,"./_meta":40,"./_redefine":44,"./_redefine-all":43,"./_set-to-string-tag":47}],13:[function(t,e,r){var n=e.exports={version:"2.0.0"};"number"==typeof __e&&(__e=n)},{}],14:[function(t,e,r){var n=t("./_a-function");e.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},{"./_a-function":5}],15:[function(t,e,r){e.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},{}],16:[function(t,e,r){e.exports=!t("./_fails")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{"./_fails":20}],17:[function(t,e,r){var n=t("./_is-object"),o=t("./_global").document,i=n(o)&&n(o.createElement);e.exports=function(t){return i?o.createElement(t):{}}},{"./_global":23,"./_is-object":31}],18:[function(t,e,r){var n=t("./_");e.exports=function(t){var e=n.getKeys(t),r=n.getSymbols;if(r)for(var o,i=r(t),s=n.isEnum,c=0;i.length>c;)s.call(t,o=i[c++])&&e.push(o);return e}},{"./_":4}],19:[function(t,e,r){var n=t("./_global"),o=t("./_core"),i=t("./_hide"),s=t("./_redefine"),c=t("./_ctx"),a="prototype",u=function(t,e,r){var f,_,l,p,d=t&u.F,h=t&u.G,v=t&u.S,g=t&u.P,y=t&u.B,m=h?n:v?n[e]||(n[e]={}):(n[e]||{})[a],b=h?o:o[e]||(o[e]={}),w=b[a]||(b[a]={});h&&(r=e);for(f in r)_=!d&&m&&void 0!==m[f],l=(_?m:r)[f],p=y&&_?c(l,n):g&&"function"==typeof l?c(Function.call,l):l,m&&!_&&s(m,f,l,t&u.U),b[f]!=l&&i(b,f,p),g&&w[f]!=l&&(w[f]=l)};n.core=o,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,e.exports=u},{"./_core":13,"./_ctx":14,"./_global":23,"./_hide":25,"./_redefine":44}],20:[function(t,e,r){e.exports=function(t){try{return!!t()}catch(e){return!0}}},{}],21:[function(t,e,r){var n=t("./_ctx"),o=t("./_iter-call"),i=t("./_is-array-iter"),s=t("./_an-object"),c=t("./_to-length"),a=t("./core.get-iterator-method");e.exports=function(t,e,r,u){var f,_,l,p=a(t),d=n(r,u,e?2:1),h=0;if("function"!=typeof p)throw TypeError(t+" is not iterable!");if(i(p))for(f=c(t.length);f>h;h++)e?d(s(_=t[h])[0],_[1]):d(t[h]);else for(l=p.call(t);!(_=l.next()).done;)o(l,d,_.value,e)}},{"./_an-object":8,"./_ctx":14,"./_is-array-iter":29,"./_iter-call":32,"./_to-length":54,"./core.get-iterator-method":57}],22:[function(t,e,r){var n=t("./_to-iobject"),o=t("./_").getNames,i={}.toString,s="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return o(t)}catch(e){return s.slice()}};e.exports.get=function(t){return s&&"[object Window]"==i.call(t)?c(t):o(n(t))}},{"./_":4,"./_to-iobject":53}],23:[function(t,e,r){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},{}],24:[function(t,e,r){var n={}.hasOwnProperty;e.exports=function(t,e){return n.call(t,e)}},{}],25:[function(t,e,r){var n=t("./_"),o=t("./_property-desc");e.exports=t("./_descriptors")?function(t,e,r){return n.setDesc(t,e,o(1,r))}:function(t,e,r){return t[e]=r,t}},{"./_":4,"./_descriptors":16,"./_property-desc":42}],26:[function(t,e,r){e.exports=t("./_global").document&&document.documentElement},{"./_global":23}],27:[function(t,e,r){e.exports=function(t,e,r){var n=void 0===r;switch(e.length){case 0:return n?t():t.call(r);case 1:return n?t(e[0]):t.call(r,e[0]);case 2:return n?t(e[0],e[1]):t.call(r,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(r,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(r,e[0],e[1],e[2],e[3])}return t.apply(r,e)}},{}],28:[function(t,e,r){var n=t("./_cof");e.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},{"./_cof":10}],29:[function(t,e,r){var n=t("./_iterators"),o=t("./_wks")("iterator"),i=Array.prototype;e.exports=function(t){return void 0!==t&&(n.Array===t||i[o]===t)}},{"./_iterators":37,"./_wks":56}],30:[function(t,e,r){var n=t("./_cof");e.exports=Array.isArray||function(t){return"Array"==n(t)}},{"./_cof":10}],31:[function(t,e,r){e.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},{}],32:[function(t,e,r){var n=t("./_an-object");e.exports=function(t,e,r,o){try{return o?e(n(r)[0],r[1]):e(r)}catch(i){var s=t["return"];throw void 0!==s&&n(s.call(t)),i}}},{"./_an-object":8}],33:[function(t,e,r){"use strict";var n=t("./_"),o=t("./_property-desc"),i=t("./_set-to-string-tag"),s={};t("./_hide")(s,t("./_wks")("iterator"),function(){return this}),e.exports=function(t,e,r){t.prototype=n.create(s,{next:o(1,r)}),i(t,e+" Iterator")}},{"./_":4,"./_hide":25,"./_property-desc":42,"./_set-to-string-tag":47,"./_wks":56}],34:[function(t,e,r){"use strict";var n=t("./_library"),o=t("./_export"),i=t("./_redefine"),s=t("./_hide"),c=t("./_has"),a=t("./_iterators"),u=t("./_iter-create"),f=t("./_set-to-string-tag"),_=t("./_").getProto,l=t("./_wks")("iterator"),p=!([].keys&&"next"in[].keys()),d="@@iterator",h="keys",v="values",g=function(){return this};e.exports=function(t,e,r,y,m,b,w){u(r,e,y);var x,j,k,S=function(t){if(!p&&t in D)return D[t];switch(t){case h:return function(){return new r(this,t)};case v:return function(){return new r(this,t)}}return function(){return new r(this,t)}},O=e+" Iterator",E=m==v,P=!1,D=t.prototype,F=D[l]||D[d]||m&&D[m],N=F||S(m),A=m?E?S("entries"):N:void 0,M="Array"==e?D.entries||F:F;if(M&&(k=_(M.call(new t)),k!==Object.prototype&&(f(k,O,!0),n||c(k,l)||s(k,l,g))),E&&F&&F.name!==v&&(P=!0,N=function(){return F.call(this)}),n&&!w||!p&&!P&&D[l]||s(D,l,N),a[e]=N,a[O]=g,m)if(x={values:E?N:S(v),keys:b?N:S(h),entries:A},w)for(j in x)j in D||i(D,j,x[j]);else o(o.P+o.F*(p||P),e,x);return x}},{"./_":4,"./_export":19,"./_has":24,"./_hide":25,"./_iter-create":33,"./_iterators":37,"./_library":39,"./_redefine":44,"./_set-to-string-tag":47,"./_wks":56}],35:[function(t,e,r){var n=t("./_wks")("iterator"),o=!1;try{var i=[7][n]();i["return"]=function(){o=!0},Array.from(i,function(){throw 2})}catch(s){}e.exports=function(t,e){if(!e&&!o)return!1;var r=!1;try{var i=[7],s=i[n]();s.next=function(){r=!0},i[n]=function(){return s},t(i)}catch(c){}return r}},{"./_wks":56}],36:[function(t,e,r){e.exports=function(t,e){return{value:e,done:!!t}}},{}],37:[function(t,e,r){e.exports={}},{}],38:[function(t,e,r){var n=t("./_"),o=t("./_to-iobject");e.exports=function(t,e){for(var r,i=o(t),s=n.getKeys(i),c=s.length,a=0;c>a;)if(i[r=s[a++]]===e)return r}},{"./_":4,"./_to-iobject":53}],39:[function(t,e,r){e.exports=!1},{}],40:[function(t,e,r){var n=t("./_uid")("meta"),o=t("./_is-object"),i=t("./_has"),s=t("./_").setDesc,c=0,a=Object.isExtensible||function(){return!0},u=!t("./_fails")(function(){return a(Object.preventExtensions({}))}),f=function(t){s(t,n,{value:{i:"O"+ ++c,w:{}}})},_=function(t,e){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,n)){if(!a(t))return"F";if(!e)return"E";f(t)}return t[n].i},l=function(t,e){if(!i(t,n)){if(!a(t))return!0;if(!e)return!1;f(t)}return t[n].w},p=function(t){return u&&d.NEED&&a(t)&&!i(t,n)&&f(t),t},d=e.exports={KEY:n,NEED:!1,fastKey:_,getWeak:l,onFreeze:p}},{"./_":4,"./_fails":20,"./_has":24,"./_is-object":31,"./_uid":55}],41:[function(t,e,r){var n,o,i,s=t("./_global"),c=t("./_task").set,a=s.MutationObserver||s.WebKitMutationObserver,u=s.process,f=s.Promise,_="process"==t("./_cof")(u),l=function(){var t,e,r;for(_&&(t=u.domain)&&(u.domain=null,t.exit());n;)e=n.domain,r=n.fn,e&&e.enter(),r(),e&&e.exit(),n=n.next;o=void 0,t&&t.enter()};if(_)i=function(){u.nextTick(l)};else if(a){var p=1,d=document.createTextNode("");new a(l).observe(d,{characterData:!0}),i=function(){d.data=p=-p}}else i=f&&f.resolve?function(){f.resolve().then(l)}:function(){c.call(s,l)};e.exports=function(t){var e={fn:t,next:void 0,domain:_&&u.domain};o&&(o.next=e),n||(n=e,i()),o=e}},{"./_cof":10,"./_global":23,"./_task":51}],42:[function(t,e,r){e.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},{}],43:[function(t,e,r){var n=t("./_redefine");e.exports=function(t,e,r){for(var o in e)n(t,o,e[o],r);return t}},{"./_redefine":44}],44:[function(t,e,r){var n=t("./_global"),o=t("./_hide"),i=t("./_uid")("src"),s="toString",c=Function[s],a=(""+c).split(s);t("./_core").inspectSource=function(t){return c.call(t)},(e.exports=function(t,e,r,s){"function"==typeof r&&(r.hasOwnProperty(i)||o(r,i,t[e]?""+t[e]:a.join(String(e))),r.hasOwnProperty("name")||o(r,"name",e)),t===n?t[e]=r:s?t[e]?t[e]=r:o(t,e,r):(delete t[e],o(t,e,r))})(Function.prototype,s,function(){return"function"==typeof this&&this[i]||c.call(this)})},{"./_core":13,"./_global":23,"./_hide":25,"./_uid":55}],45:[function(t,e,r){var n=t("./_").getDesc,o=t("./_is-object"),i=t("./_an-object"),s=function(t,e){if(i(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,r,o){try{o=t("./_ctx")(Function.call,n(Object.prototype,"__proto__").set,2),o(e,[]),r=!(e instanceof Array)}catch(i){r=!0}return function(t,e){return s(t,e),r?t.__proto__=e:o(t,e),t}}({},!1):void 0),check:s}},{"./_":4,"./_an-object":8,"./_ctx":14,"./_is-object":31}],46:[function(t,e,r){"use strict";var n=t("./_global"),o=t("./_"),i=t("./_descriptors"),s=t("./_wks")("species");e.exports=function(t){var e=n[t];i&&e&&!e[s]&&o.setDesc(e,s,{configurable:!0,get:function(){return this}})}},{"./_":4,"./_descriptors":16,"./_global":23,"./_wks":56}],47:[function(t,e,r){var n=t("./_").setDesc,o=t("./_has"),i=t("./_wks")("toStringTag");e.exports=function(t,e,r){t&&!o(t=r?t:t.prototype,i)&&n(t,i,{configurable:!0,value:e})}},{"./_":4,"./_has":24,"./_wks":56}],48:[function(t,e,r){var n=t("./_global"),o="__core-js_shared__",i=n[o]||(n[o]={});e.exports=function(t){return i[t]||(i[t]={})}},{"./_global":23}],49:[function(t,e,r){var n=t("./_an-object"),o=t("./_a-function"),i=t("./_wks")("species");e.exports=function(t,e){var r,s=n(t).constructor;return void 0===s||void 0==(r=n(s)[i])?e:o(r)}},{"./_a-function":5,"./_an-object":8,"./_wks":56}],50:[function(t,e,r){var n=t("./_to-integer"),o=t("./_defined");e.exports=function(t){return function(e,r){var i,s,c=String(o(e)),a=n(r),u=c.length;return 0>a||a>=u?t?"":void 0:(i=c.charCodeAt(a),55296>i||i>56319||a+1===u||(s=c.charCodeAt(a+1))<56320||s>57343?t?c.charAt(a):i:t?c.slice(a,a+2):(i-55296<<10)+(s-56320)+65536)}}},{"./_defined":15,"./_to-integer":52}],51:[function(t,e,r){var n,o,i,s=t("./_ctx"),c=t("./_invoke"),a=t("./_html"),u=t("./_dom-create"),f=t("./_global"),_=f.process,l=f.setImmediate,p=f.clearImmediate,d=f.MessageChannel,h=0,v={},g="onreadystatechange",y=function(){var t=+this;if(v.hasOwnProperty(t)){var e=v[t];delete v[t],e()}},m=function(t){y.call(t.data)};l&&p||(l=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return v[++h]=function(){c("function"==typeof t?t:Function(t),e)},n(h),h},p=function(t){delete v[t]},"process"==t("./_cof")(_)?n=function(t){_.nextTick(s(y,t,1))}:d?(o=new d,i=o.port2,o.port1.onmessage=m,n=s(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(n=function(t){f.postMessage(t+"","*")},f.addEventListener("message",m,!1)):n=g in u("script")?function(t){a.appendChild(u("script"))[g]=function(){a.removeChild(this),y.call(t)}}:function(t){setTimeout(s(y,t,1),0)}),e.exports={set:l,clear:p}},{"./_cof":10,"./_ctx":14,"./_dom-create":17,"./_global":23,"./_html":26,"./_invoke":27}],52:[function(t,e,r){var n=Math.ceil,o=Math.floor;e.exports=function(t){return isNaN(t=+t)?0:(t>0?o:n)(t)}},{}],53:[function(t,e,r){var n=t("./_iobject"),o=t("./_defined");e.exports=function(t){return n(o(t))}},{"./_defined":15,"./_iobject":28}],54:[function(t,e,r){var n=t("./_to-integer"),o=Math.min;e.exports=function(t){return t>0?o(n(t),9007199254740991):0}},{"./_to-integer":52}],55:[function(t,e,r){var n=0,o=Math.random();e.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+o).toString(36))}},{}],56:[function(t,e,r){var n=t("./_shared")("wks"),o=t("./_uid"),i=t("./_global").Symbol,s="function"==typeof i;e.exports=function(t){return n[t]||(n[t]=s&&i[t]||(s?i:o)("Symbol."+t))}},{"./_global":23,"./_shared":48,"./_uid":55}],57:[function(t,e,r){var n=t("./_classof"),o=t("./_wks")("iterator"),i=t("./_iterators");e.exports=t("./_core").getIteratorMethod=function(t){return void 0!=t?t[o]||t["@@iterator"]||i[n(t)]:void 0}},{"./_classof":9,"./_core":13,"./_iterators":37,"./_wks":56}],58:[function(t,e,r){"use strict";var n=t("./_add-to-unscopables"),o=t("./_iter-step"),i=t("./_iterators"),s=t("./_to-iobject");e.exports=t("./_iter-define")(Array,"Array",function(t,e){this._t=s(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):"keys"==e?o(0,r):"values"==e?o(0,t[r]):o(0,[r,t[r]])},"values"),i.Arguments=i.Array,n("keys"),n("values"),n("entries")},{"./_add-to-unscopables":6,"./_iter-define":34,"./_iter-step":36,"./_iterators":37,"./_to-iobject":53}],59:[function(t,e,r){"use strict";var n=t("./_classof"),o={};o[t("./_wks")("toStringTag")]="z",o+""!="[object z]"&&t("./_redefine")(Object.prototype,"toString",function(){return"[object "+n(this)+"]"},!0)},{"./_classof":9,"./_redefine":44,"./_wks":56}],60:[function(t,e,r){"use strict";var n,o,i,s=t("./_"),c=(t("./_library"),t("./_global")),a=t("./_ctx"),u=t("./_classof"),f=t("./_export"),_=t("./_is-object"),l=(t("./_an-object"),t("./_a-function")),p=t("./_an-instance"),d=t("./_for-of"),h=t("./_set-proto").set,v=t("./_species-constructor"),g=t("./_task").set,y=t("./_microtask"),m="Promise",b=c.TypeError,w=c.process,x=c[m],j="process"==u(w),k=function(t){var e=new x(function(){});return t&&(e.constructor=Object),x.resolve(e)===e},S=function(){var e=!1,r=function(t){var e=new x(t);return h(e,r.prototype),e};try{if(e=x&&x.resolve&&k(),h(r,x),r.prototype=s.create(x.prototype,{constructor:{value:r}}),r.resolve(5).then(function(){})instanceof r||(e=!1),e&&t("./_descriptors")){var n=!1;x.resolve(s.setDesc({},"then",{get:function(){n=!0}})),e=n}}catch(o){e=!1}return!!e}(),O=function(t,e){return t===e||t===x&&e===i},E=function(t){var e;return _(t)&&"function"==typeof(e=t.then)?e:!1},P=function(t){return O(x,t)?new D(t):new o(t)},D=o=function(t){var e,r;this.promise=new t(function(t,n){if(void 0!==e||void 0!==r)throw b("Bad Promise constructor");e=t,r=n}),this.resolve=l(e),this.reject=l(r)},F=function(t){try{t()}catch(e){return{error:e}}},N=function(t,e){if(!t._n){t._n=!0;var r=t._c;y(function(){for(var n=t._v,o=1==t._s,i=0,s=function(e){var r,i,s=o?e.ok:e.fail,c=e.resolve,a=e.reject;try{s?(o||(2==t._h&&T(t),t._h=1),r=s===!0?n:s(n),r===e.promise?a(b("Promise-chain cycle")):(i=E(r))?i.call(r,c,a):c(r)):a(n)}catch(u){a(u)}};r.length>i;)s(r[i++]);t._c=[],t._n=!1,e&&!t._h&&A(t)})}},A=function(t){g.call(c,function(){if(M(t)){var e,r,n=t._v;j?w.emit("unhandledRejection",n,t):(e=c.onunhandledrejection)?e({promise:t,reason:n}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",n),t._h=2}t._a=void 0})},M=function(t){var e,r=t._a||t._c,n=0;if(1==t._h)return!1;for(;r.length>n;)if(e=r[n++],e.fail||!M(e.promise))return!1;return!0},T=function(t){g.call(c,function(){var e;j?w.emit("rejectionHandled",t):(e=c.onrejectionhandled)&&e({promise:t,reason:t._v})})},C=function(t){var e=this;e._d||(e._d=!0,e=e._w||e,e._v=t,e._s=2,e._a||(e._a=e._c.slice()),N(e,!0))},I=function(t){var e,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw b("Promise can't be resolved itself");(e=E(t))?y(function(){var n={_w:r,_d:!1};try{e.call(t,a(I,n,1),a(C,n,1))}catch(o){C.call(n,o)}}):(r._v=t,r._s=1,N(r,!1))}catch(n){C.call({_w:r,_d:!1},n)}}};S||(x=function(t){p(this,x,m,"_h"),l(t),n.call(this);try{t(a(I,this,1),a(C,this,1))}catch(e){C.call(this,e)}},n=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},n.prototype=t("./_redefine-all")(x.prototype,{then:function(t,e){var r=P(v(this,x));return r.ok="function"==typeof t?t:!0,r.fail="function"==typeof e&&e,this._c.push(r),this._a&&this._a.push(r),this._s&&N(this,!1),r.promise},"catch":function(t){return this.then(void 0,t)}}),D=function(){var t=new n;this.promise=t,this.resolve=a(I,t,1),this.reject=a(C,t,1)}),f(f.G+f.W+f.F*!S,{Promise:x}),t("./_set-to-string-tag")(x,m),t("./_set-species")(m),i=t("./_core")[m],f(f.S+f.F*!S,m,{reject:function(t){var e=P(this),r=e.reject;return r(t),e.promise}}),f(f.S+f.F*(!S||k(!0)),m,{resolve:function(t){if(t instanceof x&&O(t.constructor,this))return t;var e=P(this),r=e.resolve;return r(t),e.promise}}),f(f.S+f.F*!(S&&t("./_iter-detect")(function(t){x.all(t)["catch"](function(){})})),m,{all:function(t){var e=this,r=P(e),n=r.resolve,o=r.reject,i=[],c=F(function(){d(t,!1,i.push,i);var r=i.length,c=Array(r);r?s.each.call(i,function(t,i){var s=!1;e.resolve(t).then(function(t){s||(s=!0,c[i]=t,--r||n(c))},o)}):n(c)});return c&&o(c.error),r.promise},race:function(t){var e=this,r=P(e),n=r.reject,o=F(function(){d(t,!1,function(t){e.resolve(t).then(r.resolve,n)})});return o&&n(o.error),r.promise}})},{"./_":4,"./_a-function":5,"./_an-instance":7,"./_an-object":8,"./_classof":9,"./_core":13,"./_ctx":14,"./_descriptors":16,"./_export":19,"./_for-of":21,"./_global":23,"./_is-object":31,"./_iter-detect":35,"./_library":39,"./_microtask":41,"./_redefine-all":43,"./_set-proto":45,"./_set-species":46,"./_set-to-string-tag":47,"./_species-constructor":49,"./_task":51}],61:[function(t,e,r){"use strict";var n=t("./_collection-strong");t("./_collection")("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return n.def(this,t=0===t?0:t,t)}},n)},{"./_collection":12,"./_collection-strong":11}],62:[function(t,e,r){"use strict";var n=t("./_string-at")(!0);t("./_iter-define")(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,r=this._i;return r>=e.length?{value:void 0,done:!0}:(t=n(e,r),this._i+=t.length,{value:t,done:!1})})},{"./_iter-define":34,"./_string-at":50}],63:[function(t,e,r){"use strict";var n=t("./_"),o=t("./_global"),i=t("./_core"),s=t("./_has"),c=t("./_descriptors"),a=t("./_export"),u=t("./_redefine"),f=t("./_meta").KEY,_=t("./_fails"),l=t("./_shared"),p=t("./_set-to-string-tag"),d=t("./_uid"),h=t("./_wks"),v=t("./_keyof"),g=t("./_get-names"),y=t("./_enum-keys"),m=t("./_is-array"),b=t("./_an-object"),w=t("./_to-iobject"),x=t("./_property-desc"),j=n.getDesc,k=n.setDesc,S=n.create,O=g.get,E=o.Symbol,P=o.JSON,D=P&&P.stringify,F=!1,N=h("_hidden"),A=n.isEnum,M=l("symbol-registry"),T=l("symbols"),C=Object.prototype,I="function"==typeof E,K=c&&_(function(){return 7!=S(k({},"a",{get:function(){return k(this,"a",{value:7}).a}})).a})?function(t,e,r){var n=j(C,e);n&&delete C[e],k(t,e,r),n&&t!==C&&k(C,e,n)}:k,L=function(t){var e=T[t]=S(E.prototype);return e._k=t,c&&F&&K(C,t,{configurable:!0,set:function(e){s(this,N)&&s(this[N],t)&&(this[N][t]=!1),K(this,t,x(1,e))}}),e},W=function(t){return"symbol"==typeof t},z=function(t,e,r){return r&&s(T,e)?(r.enumerable?(s(t,N)&&t[N][e]&&(t[N][e]=!1),r=S(r,{enumerable:x(0,!1)})):(s(t,N)||k(t,N,x(1,{})),t[N][e]=!0),K(t,e,r)):k(t,e,r)},U=function(t,e){b(t);for(var r,n=y(e=w(e)),o=0,i=n.length;i>o;)z(t,r=n[o++],e[r]);return t},G=function(t,e){return void 0===e?S(t):U(S(t),e)},q=function(t){var e=A.call(this,t);return e||!s(this,t)||!s(T,t)||s(this,N)&&this[N][t]?e:!0},J=function(t,e){var r=j(t=w(t),e);return!r||!s(T,e)||s(t,N)&&t[N][e]||(r.enumerable=!0),r},B=function(t){for(var e,r=O(w(t)),n=[],o=0;r.length>o;)s(T,e=r[o++])||e==N||e==f||n.push(e);return n},R=function(t){for(var e,r=O(w(t)),n=[],o=0;r.length>o;)s(T,e=r[o++])&&n.push(T[e]);return n},Y=function(t){if(void 0!==t&&!W(t)){for(var e,r,n=[t],o=1;arguments.length>o;)n.push(arguments[o++]);return e=n[1],"function"==typeof e&&(r=e),(r||!m(e))&&(e=function(t,e){return r&&(e=r.call(this,t,e)),W(e)?void 0:e}),n[1]=e,D.apply(P,n)}},H=_(function(){var t=E();return"[null]"!=D([t])||"{}"!=D({a:t})||"{}"!=D(Object(t))});I||(E=function(){if(W(this))throw TypeError("Symbol is not a constructor");return L(d(arguments.length>0?arguments[0]:void 0))},u(E.prototype,"toString",function(){return this._k}),W=function(t){return t instanceof E},n.create=G,n.isEnum=q,n.getDesc=J,n.setDesc=z,n.setDescs=U,n.getNames=g.get=B,n.getSymbols=R,c&&!t("./_library")&&u(C,"propertyIsEnumerable",q,!0)),a(a.G+a.W+a.F*!I,{Symbol:E}),n.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(t){var e=i.Symbol,r=h(t);t in e||k(e,t,{value:I?r:L(r)})}),F=!0,a(a.S+a.F*!I,"Symbol",{"for":function(t){return s(M,t+="")?M[t]:M[t]=E(t)},keyFor:function(t){return v(M,t)},useSetter:function(){F=!0},useSimple:function(){F=!1}}),a(a.S+a.F*!I,"Object",{create:G,defineProperty:z,defineProperties:U,getOwnPropertyDescriptor:J,getOwnPropertyNames:B,getOwnPropertySymbols:R}),P&&a(a.S+a.F*(!I||H),"JSON",{stringify:Y}),p(E,"Symbol"),p(Math,"Math",!0),p(o.JSON,"JSON",!0)},{"./_":4,"./_an-object":8,"./_core":13,"./_descriptors":16,"./_enum-keys":18,"./_export":19,"./_fails":20,"./_get-names":22,"./_global":23,"./_has":24,"./_is-array":30,"./_keyof":38,"./_library":39,"./_meta":40,"./_property-desc":42,"./_redefine":44,"./_set-to-string-tag":47,"./_shared":48,"./_to-iobject":53,"./_uid":55,"./_wks":56}],64:[function(t,e,r){var n=t("./es6.array.iterator"),o=t("./_redefine"),i=t("./_global"),s=t("./_hide"),c=t("./_iterators"),a=t("./_wks"),u=a("iterator"),f=a("toStringTag"),_=c.Array;t("./_").each.call(["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],function(t){var e,r=i[t],a=r&&r.prototype;if(a){a[u]||s(a,u,_),a[f]||s(a,f,t),c[t]=_;for(e in n)a[e]||o(a,e,n[e],!0)}})},{"./_":4,"./_global":23,"./_hide":25,"./_iterators":37,"./_redefine":44,"./_wks":56,"./es6.array.iterator":58}],65:[function(t,e,r){(function(e){"undefined"!=typeof window?(window.Symbol=t("core-js/es6/symbol"),window.Promise=t("core-js/es6/promise"),window.Set=t("core-js/es6/set")):(e.Symbol=t("core-js/es6/symbol"),e.Promise=t("core-js/es6/promise"),e.Set=t("core-js/es6/set"))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"core-js/es6/promise":1,"core-js/es6/set":2,"core-js/es6/symbol":3}]},{},[65]);

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

/**
* Based on Meteor's Base64 package.
* Rewrite with ES6 and better formated for passing
* linter
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/**
* Based on Meteor's Base64 package.
* Rewrite with ES6 and better formated for passing
* linter
*/
var BASE_64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

@@ -25,7 +25,7 @@ var BASE_64_VALS = {};

var getChar = function (val) {
var getChar = function getChar(val) {
return BASE_64_CHARS.charAt(val);
};
var getVal = function (ch) {
var getVal = function getVal(ch) {
if (ch === '=') {

@@ -39,3 +39,3 @@ return -1;

var Base64 = (function () {
var Base64 = exports.Base64 = (function () {
function Base64() {

@@ -173,3 +173,2 @@ _classCallCheck(this, Base64);

exports.Base64 = Base64;
exports['default'] = new Base64();
exports.default = new Base64();
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Collection = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _forEach = require('fast.js/forEach');
var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _forEach2 = _interopRequireDefault(_forEach);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _map2 = require('fast.js/map');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _map3 = _interopRequireDefault(_map2);
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _eventemitter = require('eventemitter3');
var _eventemitter3 = require('eventemitter3');
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _eventemitter32 = _interopRequireDefault(_eventemitter3);
var _invariant = require('invariant');

@@ -49,11 +50,19 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// Defaults
var _defaultRandomGenerator = new _Random2['default']();
var _defaultCursorClass = _CursorObservable2['default'];
var _defaultStorageManager = _StorageManager2['default'];
var _defaultIdGenerator = function (modelName) {
var _defaultRandomGenerator = new _Random2.default();
var _defaultCursorClass = _CursorObservable2.default;
var _defaultStorageManager = _StorageManager2.default;
var _defaultIdGenerator = function _defaultIdGenerator(modelName) {
var nextSeed = _defaultRandomGenerator.hexString(20);
var sequenceSeed = [nextSeed, '/collection/' + modelName];
return {
value: _Random2['default'].createWithSeed.apply(null, sequenceSeed).id(17),
value: _Random2.default.createWithSeed.apply(null, sequenceSeed).id(17),
seed: nextSeed

@@ -63,3 +72,3 @@ };

var Collection = (function (_EventEmitter) {
var Collection = exports.Collection = (function (_EventEmitter) {
_inherits(Collection, _EventEmitter);

@@ -72,11 +81,13 @@

_get(Object.getPrototypeOf(Collection.prototype), 'constructor', this).call(this);
this._methods = {};
this._modelName = name;
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Collection).call(this));
_this._methods = {};
_this._modelName = name;
// Init managers
var storageManagerClass = options.storageManager || _defaultStorageManager;
this.indexManager = new _IndexManager2['default'](this, options);
this.storageManager = new storageManagerClass(this, options);
this.idGenerator = options.idGenerator || _defaultIdGenerator;
_this.indexManager = new _IndexManager2.default(_this, options);
_this.storageManager = new storageManagerClass(_this, options);
_this.idGenerator = options.idGenerator || _defaultIdGenerator;
return _this;
}

@@ -93,3 +104,3 @@

value: function create(raw) {
return new _Document2['default'](this, raw);
return new _Document2.default(this, raw);
}

@@ -103,6 +114,7 @@

*/
}, {
key: 'static',
value: function _static(name, fn) {
(0, _invariant2['default'])(!Collection.prototype.hasOwnProperty(name) && typeof fn === 'function', 'Static function `%s` must not be an existing one in a model', name);
(0, _invariant2.default)(!Collection.prototype.hasOwnProperty(name) && typeof fn === 'function', 'Static function `%s` must not be an existing one in a model', name);
this[name] = fn;

@@ -119,6 +131,7 @@ return this;

*/
}, {
key: 'method',
value: function method(name, fn) {
(0, _invariant2['default'])(!this._methods[name] && typeof fn === 'function', 'Method function `%s` already defined in a model', name);
(0, _invariant2.default)(!this._methods[name] && typeof fn === 'function', 'Method function `%s` already defined in a model', name);
this._methods[name] = fn;

@@ -133,2 +146,3 @@ return this;

*/
}, {

@@ -147,6 +161,7 @@ key: 'ensureIndex',

*/
}, {
key: 'insert',
value: function insert(doc) {
var _this = this;
var _this2 = this;

@@ -167,4 +182,4 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

return this.indexManager.indexDocument(doc).then(function () {
return _this.storageManager.persist(doc._id, doc).then(function () {
_this.emit('insert', doc, null, randomId);
return _this2.storageManager.persist(doc._id, doc).then(function () {
_this2.emit('insert', doc, null, randomId);
return doc._id;

@@ -181,9 +196,10 @@ });

*/
}, {
key: 'insertAll',
value: function insertAll(docs, options) {
var _this2 = this;
var _this3 = this;
return Promise.all(docs.map(function (d) {
return _this2.insert(d, options);
return Promise.all((0, _map3.default)(docs, function (d) {
return _this3.insert(d, options);
}));

@@ -200,6 +216,7 @@ }

*/
}, {
key: 'remove',
value: function remove(query) {
var _this3 = this;
var _this4 = this;

@@ -215,9 +232,9 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

return this.find(query).exec().then(function (docs) {
(0, _invariant2['default'])(docs.length <= 1 || options.multi, 'remove(..): multi removing is not enabled by options.multi');
(0, _invariant2.default)(docs.length <= 1 || options.multi, 'remove(..): multi removing is not enabled by options.multi');
var removeStorgePromises = docs.map(function (d) {
return _this3.storageManager['delete'](d._id);
var removeStorgePromises = (0, _map3.default)(docs, function (d) {
return _this4.storageManager.delete(d._id);
});
var removeIndexPromises = docs.map(function (d) {
return _this3.indexManager.deindexDocument(d);
var removeIndexPromises = (0, _map3.default)(docs, function (d) {
return _this4.indexManager.deindexDocument(d);
});

@@ -227,4 +244,4 @@ var allPromises = removeStorgePromises.concat(removeIndexPromises);

return Promise.all(allPromises).then(function () {
docs.forEach(function (d) {
return _this3.emit('remove', null, d);
(0, _forEach2.default)(docs, function (d) {
return _this4.emit('remove', null, d);
});

@@ -245,6 +262,7 @@ return docs;

*/
}, {
key: 'update',
value: function update(query, modifier) {
var _this4 = this;
var _this5 = this;

@@ -261,15 +279,15 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

// Update locally
return new _DocumentModifier2['default'](this, query).modify(modifier, options).then(function (result) {
return new _DocumentModifier2.default(this, query).modify(modifier, options).then(function (result) {
var original = result.original;
var updated = result.updated;
updated = updated.map(function (x) {
return _this4.create(x);
updated = (0, _map3.default)(updated, function (x) {
return _this5.create(x);
});
var updateStorgePromises = updated.map(function (d) {
return _this4.storageManager.persist(d._id, d);
var updateStorgePromises = (0, _map3.default)(updated, function (d) {
return _this5.storageManager.persist(d._id, d);
});
var updateIndexPromises = updated.map(function (d, i) {
return _this4.indexManager.reindexDocument(original[i], d);
var updateIndexPromises = (0, _map3.default)(updated, function (d, i) {
return _this5.indexManager.reindexDocument(original[i], d);
});

@@ -279,4 +297,4 @@ var allPromises = updateStorgePromises.concat(updateIndexPromises);

return Promise.all(allPromises).then(function () {
updated.forEach(function (d, i) {
_this4.emit('update', d, original[i]);
(0, _forEach2.default)(updated, function (d, i) {
_this5.emit('update', d, original[i]);
});

@@ -296,2 +314,3 @@ return {

*/
}, {

@@ -308,2 +327,3 @@ key: 'getIndexIds',

*/
}, {

@@ -323,2 +343,3 @@ key: 'find',

*/
}, {

@@ -341,2 +362,3 @@ key: 'findOne',

*/
}, {

@@ -356,2 +378,3 @@ key: 'count',

*/
}, {

@@ -364,3 +387,3 @@ key: 'ids',

key: 'modelName',
get: function () {
get: function get() {
return this._modelName;

@@ -370,3 +393,3 @@ }

key: 'indexes',
get: function () {
get: function get() {
return this.indexManager.indexes;

@@ -376,3 +399,3 @@ }

key: 'storage',
get: function () {
get: function get() {
return this.storageManager;

@@ -398,5 +421,4 @@ }

return Collection;
})(_eventemitter32['default']);
})(_eventemitter2.default);
exports.Collection = Collection;
exports['default'] = Collection;
exports.default = Collection;
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CollectionIndex = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _invariant = require('invariant');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _invariant2 = _interopRequireDefault(_invariant);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _invariant = require('invariant');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _invariant2 = _interopRequireDefault(_invariant);
var CollectionIndex = (function () {
var CollectionIndex = exports.CollectionIndex = (function () {
function CollectionIndex() {

@@ -23,4 +24,4 @@ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

(0, _invariant2['default'])(options.fieldName, 'CollectionIndex(...): you must specify a "feildName" option');
(0, _invariant2['default'])(!Array.isArray(options.fieldName), 'CollectionIndex(...): compound index is not supported yet');
(0, _invariant2.default)(options.fieldName, 'CollectionIndex(...): you must specify a "feildName" option');
(0, _invariant2.default)(!Array.isArray(options.fieldName), 'CollectionIndex(...): compound index is not supported yet');

@@ -74,3 +75,2 @@ this.fieldName = options.fieldName;

exports.CollectionIndex = CollectionIndex;
exports['default'] = CollectionIndex;
exports.default = CollectionIndex;
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _PIPELINE_PROCESSORS;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Cursor = exports.PIPELINE_PROCESSORS = exports.PIPELINE_TYPE = undefined;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _forEach = require('fast.js/forEach');
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _forEach2 = _interopRequireDefault(_forEach);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _map2 = require('fast.js/map');
var _lodashCollectionEach = require('lodash/collection/each');
var _map3 = _interopRequireDefault(_map2);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _checkTypes = require('check-types');
var _lodashLangIsObject = require('lodash/lang/isObject');
var _checkTypes2 = _interopRequireDefault(_checkTypes);
var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
var _eventemitter = require('eventemitter3');
var _lodashLangIsArray = require('lodash/lang/isArray');
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
var _lodashLangIsEmpty = require('lodash/lang/isEmpty');
var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
var _eventemitter3 = require('eventemitter3');
var _eventemitter32 = _interopRequireDefault(_eventemitter3);
var _invariant = require('invariant');

@@ -61,2 +48,14 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// Maker used for stopping pipeline processing

@@ -66,3 +65,3 @@ var PIPLEINE_STOP_MARKER = {};

// Pipeline processors definition
var PIPELINE_TYPE = (0, _keymirror2['default'])({
var PIPELINE_TYPE = exports.PIPELINE_TYPE = (0, _keymirror2.default)({
Filter: null,

@@ -79,4 +78,3 @@ Sort: null,

exports.PIPELINE_TYPE = PIPELINE_TYPE;
var PIPELINE_PROCESSORS = (_PIPELINE_PROCESSORS = {}, _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.Filter, function (docs, pipeObj) {
var PIPELINE_PROCESSORS = exports.PIPELINE_PROCESSORS = (_PIPELINE_PROCESSORS = {}, _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.Filter, function (docs, pipeObj) {
return docs.filter(pipeObj.value);

@@ -92,3 +90,3 @@ }), _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.Sort, function (docs, pipeObj) {

}), _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.Join, function (docs, pipeObj, cursor) {
if ((0, _lodashLangIsArray2['default'])(docs)) {
if (_checkTypes2.default.array(docs)) {
return PIPELINE_PROCESSORS[PIPELINE_TYPE.JoinEach](docs, pipeObj, cursor);

@@ -99,5 +97,5 @@ } else {

}), _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.JoinEach, function (docs, pipeObj, cursor) {
docs = (0, _lodashLangIsArray2['default'])(docs) ? docs : [docs];
docs = _checkTypes2.default.array(docs) ? docs : [docs];
var docsLength = docs.length;
return Promise.all(docs.map(function (x, i) {
return Promise.all((0, _map3.default)(docs, function (x, i) {
return PIPELINE_PROCESSORS[PIPELINE_TYPE.JoinAll](x, pipeObj, cursor, i, docsLength);

@@ -112,5 +110,6 @@ }));

var res = pipeObj.value(docs, updatedFn, i, len);
res = (0, _lodashLangIsArray2['default'])(res) ? res : [res];
res.forEach(function (observeStopper) {
if ((0, _lodashLangIsObject2['default'])(observeStopper) && observeStopper.then) {
res = _checkTypes2.default.array(res) ? res : [res];
(0, _forEach2.default)(res, function (observeStopper) {
if (_checkTypes2.default.object(observeStopper) && observeStopper.then) {
if (observeStopper.parent) {

@@ -123,2 +122,3 @@ observeStopper.parent(cursor);

});
return Promise.all(res).then(function () {

@@ -128,6 +128,6 @@ return docs;

}), _defineProperty(_PIPELINE_PROCESSORS, PIPELINE_TYPE.IfNotEmpty, function (docs) {
return (0, _lodashLangIsEmpty2['default'])(docs) ? PIPLEINE_STOP_MARKER : docs;
var isEmptyRes = !_checkTypes2.default.assigned(docs) || _checkTypes2.default.array(docs) && _checkTypes2.default.emptyArray(docs) || _checkTypes2.default.object(docs) && _checkTypes2.default.emptyObject(docs);
return isEmptyRes ? PIPLEINE_STOP_MARKER : docs;
}), _PIPELINE_PROCESSORS);
exports.PIPELINE_PROCESSORS = PIPELINE_PROCESSORS;
/**

@@ -146,8 +146,10 @@ * Class for storing information about query

_get(Object.getPrototypeOf(Cursor.prototype), 'constructor', this).call(this);
this.db = db;
this._query = query;
this._pipeline = [];
this._executing = null;
this._ensureMatcherSorter();
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Cursor).call(this));
_this.db = db;
_this._query = query;
_this._pipeline = [];
_this._executing = null;
_this._ensureMatcherSorter();
return _this;
}

@@ -159,3 +161,3 @@

this._ensureNotExecuting();
(0, _invariant2['default'])(_skip >= 0 || typeof _skip === 'undefined', 'skip(...): skip must be a positive number');
(0, _invariant2.default)(_skip >= 0 || typeof _skip === 'undefined', 'skip(...): skip must be a positive number');

@@ -169,3 +171,3 @@ this._skip = _skip;

this._ensureNotExecuting();
(0, _invariant2['default'])(_limit >= 0 || typeof _limit === 'undefined', 'limit(...): limit must be a positive number');
(0, _invariant2.default)(_limit >= 0 || typeof _limit === 'undefined', 'limit(...): limit must be a positive number');

@@ -187,3 +189,3 @@ this._limit = _limit;

this._ensureNotExecuting();
(0, _invariant2['default'])(typeof sortObj === 'object' || typeof sortObj === 'undefined' || Array.isArray(sortObj), 'sort(...): argument must be an object');
(0, _invariant2.default)((typeof sortObj === 'undefined' ? 'undefined' : _typeof(sortObj)) === 'object' || typeof sortObj === 'undefined' || Array.isArray(sortObj), 'sort(...): argument must be an object');

@@ -197,3 +199,3 @@ this._sort = sortObj;

value: function sortFunc(sortFn) {
(0, _invariant2['default'])(typeof sortFn === 'function', 'sortFunc(...): argument must be a function');
(0, _invariant2.default)(typeof sortFn === 'function', 'sortFunc(...): argument must be a function');

@@ -206,3 +208,3 @@ this.addPipeline(PIPELINE_TYPE.Sort, sortFn);

value: function filter(filterFn) {
(0, _invariant2['default'])(typeof filterFn === 'function', 'filter(...): argument must be a function');
(0, _invariant2.default)(typeof filterFn === 'function', 'filter(...): argument must be a function');

@@ -215,3 +217,3 @@ this.addPipeline(PIPELINE_TYPE.Filter, filterFn);

value: function map(mapperFn) {
(0, _invariant2['default'])(typeof mapperFn === 'function', 'map(...): mapper must be a function');
(0, _invariant2.default)(typeof mapperFn === 'function', 'map(...): mapper must be a function');

@@ -224,3 +226,3 @@ this.addPipeline(PIPELINE_TYPE.Map, mapperFn);

value: function reduce(reduceFn, initial) {
(0, _invariant2['default'])(typeof reduceFn === 'function', 'reduce(...): reducer argument must be a function');
(0, _invariant2.default)(typeof reduceFn === 'function', 'reduce(...): reducer argument must be a function');

@@ -233,3 +235,3 @@ this.addPipeline(PIPELINE_TYPE.Reduce, reduceFn, initial);

value: function aggregate(aggrFn) {
(0, _invariant2['default'])(typeof aggrFn === 'function', 'aggregate(...): aggregator must be a function');
(0, _invariant2.default)(typeof aggrFn === 'function', 'aggregate(...): aggregator must be a function');

@@ -242,3 +244,3 @@ this.addPipeline(PIPELINE_TYPE.Aggregate, aggrFn);

value: function join(joinFn) {
(0, _invariant2['default'])(typeof joinFn === 'function', 'join(...): argument must be a function');
(0, _invariant2.default)(typeof joinFn === 'function', 'join(...): argument must be a function');

@@ -251,3 +253,3 @@ this.addPipeline(PIPELINE_TYPE.Join, joinFn);

value: function joinEach(joinFn) {
(0, _invariant2['default'])(typeof joinFn === 'function', 'joinEach(...): argument must be a function');
(0, _invariant2.default)(typeof joinFn === 'function', 'joinEach(...): argument must be a function');

@@ -260,3 +262,3 @@ this.addPipeline(PIPELINE_TYPE.JoinEach, joinFn);

value: function joinAll(joinFn) {
(0, _invariant2['default'])(typeof joinFn === 'function', 'joinAll(...): argument must be a function');
(0, _invariant2.default)(typeof joinFn === 'function', 'joinAll(...): argument must be a function');

@@ -276,3 +278,3 @@ this.addPipeline(PIPELINE_TYPE.JoinAll, joinFn);

this._ensureNotExecuting();
(0, _invariant2['default'])(type && PIPELINE_TYPE[type], 'Unknown pipeline processor type %s', type);
(0, _invariant2.default)(type && PIPELINE_TYPE[type], 'Unknown pipeline processor type %s', type);

@@ -293,3 +295,3 @@ for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {

value: function processPipeline(docs) {
var _this = this;
var _this2 = this;

@@ -306,3 +308,3 @@ var i = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];

} else {
return _this.processPipeline(result, i + 1);
return _this2.processPipeline(result, i + 1);
}

@@ -322,8 +324,8 @@ });

value: function exec() {
var _this2 = this;
var _this3 = this;
this._executing = this._matchObjects().then(function (docs) {
return _this2.processPipeline(docs);
return _this3.processPipeline(docs);
}).then(function (docs) {
_this2._executing = null;
_this3._executing = null;
return docs;

@@ -337,10 +339,10 @@ });

value: function ids() {
var _this3 = this;
var _this4 = this;
this._executing = this._matchObjects().then(function (docs) {
return docs.map(function (x) {
return (0, _map3.default)(docs, function (x) {
return x._id;
});
}).then(function (ids) {
_this3._executing = null;
_this4._executing = null;
return ids;

@@ -364,14 +366,14 @@ });

value: function _matchObjects() {
var _this4 = this;
var _this5 = this;
return new _DocumentRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
return new _DocumentRetriver2.default(this.db).retriveForQeury(this._query).then(function (docs) {
var results = [];
var withFastLimit = _this4._limit && !_this4._skip && !_this4._sorter;
var withFastLimit = _this5._limit && !_this5._skip && !_this5._sorter;
(0, _lodashCollectionEach2['default'])(docs, function (d) {
var match = _this4._matcher.documentMatches(d);
(0, _forEach2.default)(docs, function (d) {
var match = _this5._matcher.documentMatches(d);
if (match.result) {
results.push(d);
}
if (withFastLimit && results.length === _this4._limit) {
if (withFastLimit && results.length === _this5._limit) {
return false;

@@ -385,8 +387,8 @@ }

if (_this4._sorter) {
var comparator = _this4._sorter.getComparator();
if (_this5._sorter) {
var comparator = _this5._sorter.getComparator();
results.sort(comparator);
}
return _this4.processSkipLimits(results);
return _this5.processSkipLimits(results);
});

@@ -398,6 +400,6 @@ }

this._sorter = undefined;
this._matcher = new _DocumentMatcher2['default'](this._query || {});
this._matcher = new _DocumentMatcher2.default(this._query || {});
if (this._matcher.hasGeoQuery || this._sort) {
this._sorter = new _DocumentSorter2['default'](this._sort || [], { matcher: this._matcher });
this._sorter = new _DocumentSorter2.default(this._sort || [], { matcher: this._matcher });
}

@@ -408,7 +410,7 @@ }

value: function _ensureNotExecuting() {
(0, _invariant2['default'])(!this.isExecuting, '_ensureNotExecuting(...): cursor is executing, cursor is immutable!');
(0, _invariant2.default)(!this.isExecuting, '_ensureNotExecuting(...): cursor is executing, cursor is immutable!');
}
}, {
key: 'isExecuting',
get: function () {
get: function get() {
return !!this._executing;

@@ -419,5 +421,5 @@ }

return Cursor;
})(_eventemitter32['default']);
})(_eventemitter2.default);
exports.Cursor = Cursor;
exports['default'] = Cursor;
exports.default = Cursor;
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
exports.CursorObservable = undefined;
exports.debounce = debounce;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _checkTypes = require('check-types');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _checkTypes2 = _interopRequireDefault(_checkTypes);
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _map2 = require('fast.js/map');
var _lodashCollectionSize = require('lodash/collection/size');
var _map3 = _interopRequireDefault(_map2);
var _lodashCollectionSize2 = _interopRequireDefault(_lodashCollectionSize);
var _keys2 = require('fast.js/object/keys');
var _lodashLangIsArray = require('lodash/lang/isArray');
var _keys3 = _interopRequireDefault(_keys2);
var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
var _Cursor2 = require('./Cursor');

@@ -35,2 +31,10 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -47,19 +51,10 @@ * Observable cursor is used for making request auto-updatable

_get(Object.getPrototypeOf(CursorObservable.prototype), 'constructor', this).call(this, db, query);
this.update = debounce(this.update.bind(this), 1000 / 15, 10);
this.maybeUpdate = this.maybeUpdate.bind(this);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(CursorObservable).call(this, db, query));
_this.update = debounce(_this.update.bind(_this), 1000 / 15, 10);
_this.maybeUpdate = _this.maybeUpdate.bind(_this);
return _this;
}
/**
* Debounce with updetable wait time and force
* execution on some number of calls (batch execution)
* Return promise that resolved with result of execution.
* Promise cerated on each new execution (on idle).
* @param {Function} func
* @param {Number} wait
* @param {Number} batchSize
* @return {Promise}
*/
/**
* Change a batch size of updater.

@@ -86,2 +81,3 @@ * Btach size is a number of changes must be happen

*/
}, {

@@ -111,6 +107,7 @@ key: 'debounce',

*/
}, {
key: 'observe',
value: function observe(listener) {
var _this = this;
var _this2 = this;

@@ -121,4 +118,4 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

// multiple times (for removeListener)
var updateWrapper = function (a, b) {
return _this.maybeUpdate(a, b);
var updateWrapper = function updateWrapper(a, b) {
return _this2.maybeUpdate(a, b);
};

@@ -129,8 +126,8 @@ this.db.on('insert', updateWrapper);

var stopper = function () {
_this.db.removeListener('insert', updateWrapper);
_this.db.removeListener('update', updateWrapper);
_this.db.removeListener('remove', updateWrapper);
_this.removeListener('update', listener);
_this.emit('stopped', listener);
var stopper = function stopper() {
_this2.db.removeListener('insert', updateWrapper);
_this2.db.removeListener('update', updateWrapper);
_this2.db.removeListener('remove', updateWrapper);
_this2.removeListener('update', listener);
_this2.emit('stopped', listener);
};

@@ -142,14 +139,18 @@

var parentSetter = function (cursor) {
_this._parentCursor = cursor;
var parentSetter = function parentSetter(cursor) {
_this2._parentCursor = cursor;
};
var createStoppablePromise = function (currPromise) {
var cursorThenGenerator = function cursorThenGenerator(currPromise) {
return function (successFn, failFn) {
successFn = _this2._prepareListener(successFn);
return createStoppablePromise(currPromise.then(successFn, failFn));
};
};
var createStoppablePromise = function createStoppablePromise(currPromise) {
return {
parent: parentSetter,
stop: stopper,
then: function (successFn, failFn) {
successFn = _this._prepareListener(successFn);
return createStoppablePromise(currPromise.then(successFn, failFn));
}
then: cursorThenGenerator(currPromise)
};

@@ -171,2 +172,3 @@ };

*/
}, {

@@ -185,6 +187,7 @@ key: 'stopObservers',

*/
}, {
key: 'update',
value: function update() {
var _this2 = this;
var _this3 = this;

@@ -194,5 +197,5 @@ var firstRun = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];

return this.exec().then(function (result) {
_this2._latestResult = result;
_this2._updateLatestIds();
_this2._propagateUpdate(firstRun);
_this3._latestResult = result;
_this3._updateLatestIds();
_this3._propagateUpdate(firstRun);
return result;

@@ -215,2 +218,3 @@ });

*/
}, {

@@ -228,3 +232,3 @@ key: 'maybeUpdate',

// 4. Is a new doc not equals to an old doc?
var updatedInResult = removedFromResult || newDoc && oldDoc && (this._matcher.documentMatches(newDoc).result || this._matcher.documentMatches(oldDoc).result) && ((0, _lodashCollectionSize2['default'])(newDoc) !== (0, _lodashCollectionSize2['default'])(oldDoc) || newDoc.updatedAt && (!oldDoc.updatedAt || oldDoc.updatedAt && newDoc.updatedAt > oldDoc.updatedAt) || !_EJSON2['default'].equals(newDoc, oldDoc));
var updatedInResult = removedFromResult || newDoc && oldDoc && (this._matcher.documentMatches(newDoc).result || this._matcher.documentMatches(oldDoc).result) && ((0, _keys3.default)(newDoc).length !== (0, _keys3.default)(oldDoc).length || newDoc.updatedAt && (!oldDoc.updatedAt || oldDoc.updatedAt && newDoc.updatedAt > oldDoc.updatedAt) || !_EJSON2.default.equals(newDoc, oldDoc));

@@ -250,2 +254,3 @@ // When it's an insert operation we just check

*/
}, {

@@ -264,2 +269,3 @@ key: '_prepareListener',

*/
}, {

@@ -280,7 +286,8 @@ key: '_propagateUpdate',

*/
}, {
key: '_updateLatestIds',
value: function _updateLatestIds() {
if ((0, _lodashLangIsArray2['default'])(this._latestResult)) {
this._latestIds = new Set(this._latestResult.map(function (x) {
if (_checkTypes2.default.array(this._latestResult)) {
this._latestIds = new Set((0, _map3.default)(this._latestResult, function (x) {
return x._id;

@@ -295,6 +302,16 @@ }));

return CursorObservable;
})(_Cursor3['default']);
})(_Cursor3.default);
/**
* Debounce with updetable wait time and force
* execution on some number of calls (batch execution)
* Return promise that resolved with result of execution.
* Promise cerated on each new execution (on idle).
* @param {Function} func
* @param {Number} wait
* @param {Number} batchSize
* @return {Promise}
*/
exports.CursorObservable = CursorObservable;
function debounce(func, wait, batchSize) {

@@ -307,3 +324,3 @@ var timeout = null;

var debouncer = function () {
var debouncer = function debouncer() {
var context = this;

@@ -343,11 +360,11 @@ var args = arguments;

var updateBatchSize = function (newBatchSize) {
var updateBatchSize = function updateBatchSize(newBatchSize) {
batchSize = newBatchSize;
};
var updateWait = function (newWait) {
var updateWait = function updateWait(newWait) {
wait = newWait;
};
var cancel = function () {
var cancel = function cancel() {
clearTimeout(timeout);

@@ -362,2 +379,2 @@ };

exports['default'] = CursorObservable;
exports.default = CursorObservable;
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MongoTypeComp = undefined;
exports.Document = Document;

@@ -15,24 +16,18 @@ exports.selectorIsId = selectorIsId;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _assign2 = require('fast.js/object/assign');
var _lodashObjectAssign = require('lodash/object/assign');
var _assign3 = _interopRequireDefault(_assign2);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _checkTypes = require('check-types');
var _lodashLangIsArray = require('lodash/lang/isArray');
var _checkTypes2 = _interopRequireDefault(_checkTypes);
var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
var _forEach = require('fast.js/forEach');
var _lodashLangIsString = require('lodash/lang/isString');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
var _keys2 = require('fast.js/object/keys');
var _lodashCollectionEach = require('lodash/collection/each');
var _keys3 = _interopRequireDefault(_keys2);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashCollectionSize = require('lodash/collection/size');
var _lodashCollectionSize2 = _interopRequireDefault(_lodashCollectionSize);
var _invariant = require('invariant');

@@ -46,2 +41,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
/*

@@ -52,3 +51,2 @@ * Instance of a model (Document)

*/
function Document(db) {

@@ -59,11 +57,11 @@ var _this = this;

(0, _invariant2['default'])(db, 'Document(...): you must give a collection for the document');
(0, _invariant2.default)(db, 'Document(...): you must give a collection for the document');
// Ensure raw object
raw = (0, _lodashLangIsString2['default'])(raw) ? _EJSON2['default'].parse(raw) : raw;
raw = _checkTypes2.default.string(raw) ? _EJSON2.default.parse(raw) : raw;
// Define internal methods
Object.defineProperty(this, 'remove', {
value: function () {
(0, _invariant2['default'])(_this._id, 'remove(...): document must have an _id for remove');
value: function value() {
(0, _invariant2.default)(_this._id, 'remove(...): document must have an _id for remove');
return db.remove({ _id: self._id });

@@ -75,4 +73,4 @@ },

Object.defineProperty(this, 'update', {
value: function (modifier) {
(0, _invariant2['default'])(this._id, 'update(...): document must have an _id for update');
value: function value(modifier) {
(0, _invariant2.default)(this._id, 'update(...): document must have an _id for update');
return db.update({ _id: self._id }, modifier);

@@ -84,4 +82,4 @@ },

Object.defineProperty(this, 'copy', {
value: function () {
return new Document(db, _EJSON2['default'].clone(_this));
value: function value() {
return new Document(db, _EJSON2.default.clone(_this));
},

@@ -92,4 +90,4 @@ writable: false

Object.defineProperty(this, 'serialize', {
value: function () {
return _EJSON2['default'].stringify(_this);
value: function value() {
return _EJSON2.default.stringify(_this);
},

@@ -108,6 +106,6 @@ writable: false

// Move given raw object to a Document
(0, _lodashObjectAssign2['default'])(this, raw);
(0, _assign3.default)(this, raw);
}
exports['default'] = Document;
exports.default = Document;

@@ -126,3 +124,3 @@ /**

function selectorIsIdPerhapsAsObject(selector) {
return selectorIsId(selector) || selector && typeof selector === 'object' && selector._id && selectorIsId(selector._id) && (0, _lodashCollectionSize2['default'])(selector) === 1;
return selectorIsId(selector) || selector && (typeof selector === 'undefined' ? 'undefined' : _typeof(selector)) === 'object' && selector._id && selectorIsId(selector._id) && (0, _keys3.default)(selector).length === 1;
}

@@ -133,5 +131,4 @@

// XXX maybe this should be EJSON.isArray
function isArray(x) {
return (0, _lodashLangIsArray2['default'])(x) && !_EJSON2['default'].isBinary(x);
return _checkTypes2.default.array(x) && !_EJSON2.default.isBinary(x);
}

@@ -142,3 +139,2 @@

// XXX note that _type(undefined) === 3!!!!
function isPlainObject(x) {

@@ -155,3 +151,2 @@ return x && MongoTypeComp._type(x) === 3;

// others don't.
function isOperatorObject(valueSelector, inconsistentOK) {

@@ -163,3 +158,3 @@ if (!isPlainObject(valueSelector)) {

var theseAreOperators = undefined;
(0, _lodashCollectionEach2['default'])(valueSelector, function (value, selKey) {
(0, _forEach2.default)(valueSelector, function (value, selKey) {
var thisIsOperator = selKey.substr(0, 1) === '$';

@@ -179,3 +174,2 @@ if (theseAreOperators === undefined) {

// string can be converted to integer
function isNumericKey(s) {

@@ -187,6 +181,6 @@ return (/^[0-9]+$/.test(s)

// helpers used by compiled selector code
var MongoTypeComp = {
var MongoTypeComp = exports.MongoTypeComp = {
// XXX for _all and _in, consider building 'inquery' at compile time..
_type: function (v) {
_type: function _type(v) {
if (typeof v === 'number') {

@@ -209,3 +203,3 @@ return 1;

return 9;
} else if (_EJSON2['default'].isBinary(v)) {
} else if (_EJSON2.default.isBinary(v)) {
return 5;

@@ -225,4 +219,4 @@ }

// deep equality test: use for literal document and array matches
_equal: function (a, b) {
return _EJSON2['default'].equals(a, b, { keyOrderSensitive: true });
_equal: function _equal(a, b) {
return _EJSON2.default.equals(a, b, { keyOrderSensitive: true });
},

@@ -232,3 +226,3 @@

// different types
_typeorder: function (t) {
_typeorder: function _typeorder(t) {
// http://www.mongodb.org/display/DOCS/What+is+the+Compare+Order+for+BSON+Types

@@ -264,3 +258,3 @@ // XXX what is the correct sort position for Javascript code?

// less, or 0 if equal
_cmp: function (a, b) {
_cmp: function _cmp(a, b) {
if (a === undefined) {

@@ -310,3 +304,3 @@ return b === undefined ? 0 : -1;

// this could be much more efficient in the expected case ...
var to_array = function (obj) {
var to_array = function to_array(obj) {
var ret = [];

@@ -382,3 +376,2 @@ for (var key in obj) {

}
};
exports.MongoTypeComp = MongoTypeComp;
};
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
exports.ELEMENT_OPERATORS = exports.DocumentMatcher = undefined;
exports.regexpElementMatcher = regexpElementMatcher;

@@ -14,62 +14,34 @@ exports.equalityElementMatcher = equalityElementMatcher;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _checkTypes = require('check-types');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _checkTypes2 = _interopRequireDefault(_checkTypes);
var _lodashLangIsEmpty = require('lodash/lang/isEmpty');
var _forEach = require('fast.js/forEach');
var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashLangIsEqual = require('lodash/lang/isEqual');
var _keys2 = require('fast.js/object/keys');
var _lodashLangIsEqual2 = _interopRequireDefault(_lodashLangIsEqual);
var _keys3 = _interopRequireDefault(_keys2);
var _lodashLangIsArray = require('lodash/lang/isArray');
var _map2 = require('fast.js/map');
var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
var _map3 = _interopRequireDefault(_map2);
var _lodashLangIsNumber = require('lodash/lang/isNumber');
var _some2 = require('fast.js/array/some');
var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
var _some3 = _interopRequireDefault(_some2);
var _lodashLangIsObject = require('lodash/lang/isObject');
var _every2 = require('fast.js/array/every');
var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
var _every3 = _interopRequireDefault(_every2);
var _lodashLangIsNaN = require('lodash/lang/isNaN');
var _indexOf2 = require('fast.js/array/indexOf');
var _lodashLangIsNaN2 = _interopRequireDefault(_lodashLangIsNaN);
var _indexOf3 = _interopRequireDefault(_indexOf2);
var _lodashObjectHas = require('lodash/object/has');
var _geojsonUtils = require('geojson-utils');
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
var _geojsonUtils2 = _interopRequireDefault(_geojsonUtils);
var _lodashObjectKeys = require('lodash/object/keys');
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _lodashCollectionEach = require('lodash/collection/each');
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashCollectionContains = require('lodash/collection/contains');
var _lodashCollectionContains2 = _interopRequireDefault(_lodashCollectionContains);
var _lodashCollectionAll = require('lodash/collection/all');
var _lodashCollectionAll2 = _interopRequireDefault(_lodashCollectionAll);
var _lodashCollectionMap = require('lodash/collection/map');
var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
var _lodashCollectionAny = require('lodash/collection/any');
var _lodashCollectionAny2 = _interopRequireDefault(_lodashCollectionAny);
var _lodashUtilityIdentity = require('lodash/utility/identity');
var _lodashUtilityIdentity2 = _interopRequireDefault(_lodashUtilityIdentity);
var _EJSON = require('./EJSON');

@@ -79,8 +51,10 @@

var _geojsonUtils = require('geojson-utils');
var _Document = require('./Document');
var _geojsonUtils2 = _interopRequireDefault(_geojsonUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _Document = require('./Document');
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// The minimongo selector compiler!

@@ -107,3 +81,3 @@

var DocumentMatcher = (function () {
var DocumentMatcher = exports.DocumentMatcher = (function () {
function DocumentMatcher(selector) {

@@ -138,3 +112,3 @@ _classCallCheck(this, DocumentMatcher);

value: function documentMatches(doc) {
if (!doc || typeof doc !== 'object') {
if (!doc || (typeof doc === 'undefined' ? 'undefined' : _typeof(doc)) !== 'object') {
throw Error('documentMatches needs a document');

@@ -165,3 +139,3 @@ }

return function (doc) {
return { result: _EJSON2['default'].equals(doc._id, selector) };
return { result: _EJSON2.default.equals(doc._id, selector) };
};

@@ -179,7 +153,7 @@ }

// Top level can't be an array or true or binary.
if (typeof selector === 'boolean' || (0, _Document.isArray)(selector) || _EJSON2['default'].isBinary(selector)) {
if (typeof selector === 'boolean' || (0, _Document.isArray)(selector) || _EJSON2.default.isBinary(selector)) {
throw new Error('Invalid selector: ' + selector);
}
this._selector = _EJSON2['default'].clone(selector);
this._selector = _EJSON2.default.clone(selector);
return compileDocumentSelector(selector, this, { isRoot: true });

@@ -195,10 +169,11 @@ }

// the empty string if there is a $where.
}, {
key: '_getPaths',
value: function _getPaths() {
return (0, _lodashObjectKeys2['default'])(this._paths);
return _checkTypes2.default.object(this._paths) ? (0, _keys3.default)(this._paths) : null;
}
}, {
key: 'hasGeoQuery',
get: function () {
get: function get() {
return this._hasGeoQuery;

@@ -208,3 +183,3 @@ }

key: 'hasWhere',
get: function () {
get: function get() {
return this._hasWhere;

@@ -214,3 +189,3 @@ }

key: 'isSimple',
get: function () {
get: function get() {
return this._isSimple;

@@ -223,4 +198,3 @@ }

exports.DocumentMatcher = DocumentMatcher;
exports['default'] = DocumentMatcher;
exports.default = DocumentMatcher;

@@ -234,11 +208,12 @@ // Takes in a selector that could match a full document (eg, the original

// then isRoot is true. (This is used by $near.)
var compileDocumentSelector = function (docSelector, matcher) {
var compileDocumentSelector = function compileDocumentSelector(docSelector, matcher) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var docMatchers = [];
(0, _lodashCollectionEach2['default'])(docSelector, function (subSelector, key) {
(0, _forEach2.default)(docSelector, function (subSelector, key) {
if (key.substr(0, 1) === '$') {
// Outer operators are either logical operators (they recurse back into
// this function), or $where.
if (!(0, _lodashObjectHas2['default'])(LOGICAL_OPERATORS, key)) {
if (!LOGICAL_OPERATORS.hasOwnProperty(key)) {
throw new Error('Unrecognized logical operator: ' + key);

@@ -271,3 +246,3 @@ }

// [branched value]->result object.
var compileValueSelector = function (valueSelector, matcher, isRoot) {
var compileValueSelector = function compileValueSelector(valueSelector, matcher, isRoot) {
if (valueSelector instanceof RegExp) {

@@ -286,3 +261,3 @@ matcher._isSimple = false;

// more structured return value possibly including arrayIndices).
var convertElementMatcherToBranchedMatcher = function (elementMatcher) {
var convertElementMatcherToBranchedMatcher = function convertElementMatcherToBranchedMatcher(elementMatcher) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -296,3 +271,3 @@

var ret = {};
ret.result = (0, _lodashCollectionAny2['default'])(expanded, function (element) {
ret.result = (0, _some3.default)(expanded, function (element) {
var matched = elementMatcher(element.value);

@@ -325,3 +300,2 @@

// Takes a RegExp object and returns an element matcher.
function regexpElementMatcher(regexp) {

@@ -332,3 +306,3 @@ return function (value) {

// (really!). Underscore knows how.
return (0, _lodashLangIsEqual2['default'])(value, regexp);
return String(value) === String(regexp);
}

@@ -353,3 +327,2 @@ // Regexps only work against strings.

// for equality with that thing.
function equalityElementMatcher(elementSelector) {

@@ -377,3 +350,3 @@ if ((0, _Document.isOperatorObject)(elementSelector)) {

// matcher for it.
var operatorBranchedMatcher = function (valueSelector, matcher, isRoot) {
var operatorBranchedMatcher = function operatorBranchedMatcher(valueSelector, matcher, isRoot) {
// Each valueSelector works separately on the various branches. So one

@@ -384,7 +357,7 @@ // operator can match one branch and another can match another branch. This

var operatorMatchers = [];
(0, _lodashCollectionEach2['default'])(valueSelector, function (operand, operator) {
(0, _forEach2.default)(valueSelector, function (operand, operator) {
// XXX we should actually implement $eq, which is new in 2.6
var simpleRange = (0, _lodashCollectionContains2['default'])(['$lt', '$lte', '$gt', '$gte'], operator) && (0, _lodashLangIsNumber2['default'])(operand);
var simpleInequality = operator === '$ne' && !(0, _lodashLangIsObject2['default'])(operand);
var simpleInclusion = (0, _lodashCollectionContains2['default'])(['$in', '$nin'], operator) && (0, _lodashLangIsArray2['default'])(operand) && !(0, _lodashCollectionAny2['default'])(operand, _lodashLangIsObject2['default']);
var simpleRange = (0, _indexOf3.default)(['$lt', '$lte', '$gt', '$gte'], operator) >= 0 && _checkTypes2.default.number(operand);
var simpleInequality = operator === '$ne' && !_checkTypes2.default.object(operand);
var simpleInclusion = (0, _indexOf3.default)(['$in', '$nin'], operator) >= 0 && _checkTypes2.default.array(operand) && !(0, _some3.default)(operand, _checkTypes2.default.object);

@@ -395,5 +368,5 @@ if (!(operator === '$eq' || simpleRange || simpleInclusion || simpleInequality)) {

if ((0, _lodashObjectHas2['default'])(VALUE_OPERATORS, operator)) {
if (VALUE_OPERATORS.hasOwnProperty(operator)) {
operatorMatchers.push(VALUE_OPERATORS[operator](operand, valueSelector, matcher, isRoot));
} else if ((0, _lodashObjectHas2['default'])(ELEMENT_OPERATORS, operator)) {
} else if (ELEMENT_OPERATORS.hasOwnProperty(operator)) {
var options = ELEMENT_OPERATORS[operator];

@@ -409,7 +382,7 @@ operatorMatchers.push(convertElementMatcherToBranchedMatcher(options.compileElementSelector(operand, valueSelector, matcher), options));

var compileArrayOfDocumentSelectors = function (selectors, matcher, inElemMatch) {
if (!(0, _Document.isArray)(selectors) || (0, _lodashLangIsEmpty2['default'])(selectors)) {
var compileArrayOfDocumentSelectors = function compileArrayOfDocumentSelectors(selectors, matcher, inElemMatch) {
if (!(0, _Document.isArray)(selectors) || _checkTypes2.default.emptyArray(selectors)) {
throw Error('$and/$or/$nor must be nonempty array');
}
return (0, _lodashCollectionMap2['default'])(selectors, function (subSelector) {
return (0, _map3.default)(selectors, function (subSelector) {
if (!(0, _Document.isPlainObject)(subSelector)) {

@@ -424,3 +397,3 @@ throw Error('$or/$and/$nor entries need to be full objects');

var LOGICAL_OPERATORS = {
$and: function (subSelector, matcher, inElemMatch) {
$and: function $and(subSelector, matcher, inElemMatch) {
var matchers = compileArrayOfDocumentSelectors(subSelector, matcher, inElemMatch);

@@ -430,3 +403,3 @@ return andDocumentMatchers(matchers);

$or: function (subSelector, matcher, inElemMatch) {
$or: function $or(subSelector, matcher, inElemMatch) {
var matchers = compileArrayOfDocumentSelectors(subSelector, matcher, inElemMatch);

@@ -441,3 +414,3 @@

return function (doc) {
var result = (0, _lodashCollectionAny2['default'])(matchers, function (f) {
var result = (0, _some3.default)(matchers, function (f) {
return f(doc).result;

@@ -451,6 +424,6 @@ });

$nor: function (subSelector, matcher, inElemMatch) {
$nor: function $nor(subSelector, matcher, inElemMatch) {
var matchers = compileArrayOfDocumentSelectors(subSelector, matcher, inElemMatch);
return function (doc) {
var result = (0, _lodashCollectionAll2['default'])(matchers, function (f) {
var result = (0, _every3.default)(matchers, function (f) {
return !f(doc).result;

@@ -464,3 +437,3 @@ });

$where: function (selectorValue, matcher) {
$where: function $where(selectorValue, matcher) {
// Record that *any* path may be used.

@@ -483,3 +456,3 @@ matcher._recordPathUsed('');

// query logs); it has no effect on the actual selection.
$comment: function () {
$comment: function $comment() {
return function () {

@@ -494,3 +467,3 @@ return { result: true };

// means that ALL branch values need to fail to match innerBranchedMatcher.
var invertBranchedMatcher = function (branchedMatcher) {
var invertBranchedMatcher = function invertBranchedMatcher(branchedMatcher) {
return function (branchValues) {

@@ -510,12 +483,12 @@ var invertMe = branchedMatcher(branchValues);

var VALUE_OPERATORS = {
$not: function (operand, valueSelector, matcher) {
$not: function $not(operand, valueSelector, matcher) {
return invertBranchedMatcher(compileValueSelector(operand, matcher));
},
$ne: function (operand) {
$ne: function $ne(operand) {
return invertBranchedMatcher(convertElementMatcherToBranchedMatcher(equalityElementMatcher(operand)));
},
$nin: function (operand) {
$nin: function $nin(operand) {
return invertBranchedMatcher(convertElementMatcherToBranchedMatcher(ELEMENT_OPERATORS.$in.compileElementSelector(operand)));
},
$exists: function (operand) {
$exists: function $exists(operand) {
var exists = convertElementMatcherToBranchedMatcher(function (value) {

@@ -527,4 +500,4 @@ return value !== undefined;

// $options just provides options for $regex; its logic is inside $regex
$options: function (operand, valueSelector) {
if (!(0, _lodashObjectHas2['default'])(valueSelector, '$regex')) {
$options: function $options(operand, valueSelector) {
if (!_checkTypes2.default.object(valueSelector) || !valueSelector.hasOwnProperty('$regex')) {
throw Error('$options needs a $regex');

@@ -535,3 +508,3 @@ }

// $maxDistance is basically an argument to $near
$maxDistance: function (operand, valueSelector) {
$maxDistance: function $maxDistance(operand, valueSelector) {
if (!valueSelector.$near) {

@@ -542,3 +515,3 @@ throw Error('$maxDistance needs a $near');

},
$all: function (operand, valueSelector, matcher) {
$all: function $all(operand, valueSelector, matcher) {
if (!(0, _Document.isArray)(operand)) {

@@ -548,3 +521,3 @@ throw Error('$all requires array');

// Not sure why, but this seems to be what MongoDB does.
if ((0, _lodashLangIsEmpty2['default'])(operand)) {
if (_checkTypes2.default.emptyArray(operand)) {
return nothingMatcher;

@@ -554,3 +527,3 @@ }

var branchedMatchers = [];
(0, _lodashCollectionEach2['default'])(operand, function (criterion) {
(0, _forEach2.default)(operand, function (criterion) {
// XXX handle $all/$elemMatch combination

@@ -567,3 +540,3 @@ if ((0, _Document.isOperatorObject)(criterion)) {

},
$near: function (operand, valueSelector, matcher, isRoot) {
$near: function $near(operand, valueSelector, matcher, isRoot) {
if (!isRoot) {

@@ -579,3 +552,3 @@ throw Error('$near can\'t be inside another $ operator');

var maxDistance, point, distance;
if ((0, _Document.isPlainObject)(operand) && (0, _lodashObjectHas2['default'])(operand, '$geometry')) {
if ((0, _Document.isPlainObject)(operand) && operand.hasOwnProperty('$geometry')) {
// GeoJSON '2dsphere' mode.

@@ -592,5 +565,5 @@ maxDistance = operand.$maxDistance;

if (value.type === 'Point') {
return _geojsonUtils2['default'].pointDistance(point, value);
return _geojsonUtils2.default.pointDistance(point, value);
} else {
return _geojsonUtils2['default'].geometryWithinRadius(value, point, maxDistance) ? 0 : maxDistance + 1;
return _geojsonUtils2.default.geometryWithinRadius(value, point, maxDistance) ? 0 : maxDistance + 1;
}

@@ -623,3 +596,3 @@ };

var result = { result: false };
(0, _lodashCollectionEach2['default'])(branchedValues, function (branch) {
(0, _forEach2.default)(branchedValues, function (branch) {
var curDistance = distance(branch.value);

@@ -648,3 +621,3 @@ // Skip branches that aren't real points or are too far away.

// Helpers for $near.
var distanceCoordinatePairs = function (a, b) {
var distanceCoordinatePairs = function distanceCoordinatePairs(a, b) {
a = pointToArray(a);

@@ -654,3 +627,3 @@ b = pointToArray(b);

var y = a[1] - b[1];
if ((0, _lodashLangIsNaN2['default'])(x) || (0, _lodashLangIsNaN2['default'])(y)) {
if (!_checkTypes2.default.number(x) || !_checkTypes2.default.number(y)) {
return null;

@@ -664,10 +637,12 @@ }

// In case user passes { lon: x, lat: y } returns [x, y]
var pointToArray = function (point) {
return (0, _lodashCollectionMap2['default'])(point, _lodashUtilityIdentity2['default']);
var pointToArray = function pointToArray(point) {
return (0, _map3.default)(point, function (x) {
return x;
});
};
// Helper for $lt/$gt/$lte/$gte.
var makeInequality = function (cmpValueComparator) {
var makeInequality = function makeInequality(cmpValueComparator) {
return {
compileElementSelector: function (operand) {
compileElementSelector: function compileElementSelector(operand) {
// Arrays never compare false with non-arrays for any inequality.

@@ -718,3 +693,3 @@ // XXX This was behavior we observed in pre-release MongoDB 2.5, but

// expandArraysInBranches if it is called
var ELEMENT_OPERATORS = {
var ELEMENT_OPERATORS = exports.ELEMENT_OPERATORS = {
$lt: makeInequality(function (cmpValue) {

@@ -733,3 +708,3 @@ return cmpValue < 0;

$mod: {
compileElementSelector: function (operand) {
compileElementSelector: function compileElementSelector(operand) {
if (!((0, _Document.isArray)(operand) && operand.length === 2 && typeof operand[0] === 'number' && typeof operand[1] === 'number')) {

@@ -747,3 +722,3 @@ throw Error('argument to $mod must be an array of two numbers');

$in: {
compileElementSelector: function (operand) {
compileElementSelector: function compileElementSelector(operand) {
if (!(0, _Document.isArray)(operand)) {

@@ -754,3 +729,3 @@ throw Error('$in needs an array');

var elementMatchers = [];
(0, _lodashCollectionEach2['default'])(operand, function (option) {
(0, _forEach2.default)(operand, function (option) {
if (option instanceof RegExp) {

@@ -770,3 +745,3 @@ elementMatchers.push(regexpElementMatcher(option));

}
return (0, _lodashCollectionAny2['default'])(elementMatchers, function (e) {
return (0, _some3.default)(elementMatchers, function (e) {
return e(value);

@@ -782,3 +757,3 @@ });

dontExpandLeafArrays: true,
compileElementSelector: function (operand) {
compileElementSelector: function compileElementSelector(operand) {
if (typeof operand === 'string') {

@@ -802,3 +777,3 @@ // Don't ask me why, but by experimentation, this seems to be what Mongo

dontIncludeLeafArrays: true,
compileElementSelector: function (operand) {
compileElementSelector: function compileElementSelector(operand) {
if (typeof operand !== 'number') {

@@ -813,3 +788,3 @@ throw Error('$type needs a number');

$regex: {
compileElementSelector: function (operand, valueSelector) {
compileElementSelector: function compileElementSelector(operand, valueSelector) {
if (!(typeof operand === 'string' || operand instanceof RegExp)) {

@@ -844,3 +819,3 @@ throw Error('$regex has to be a string or RegExp');

dontExpandLeafArrays: true,
compileElementSelector: function (operand, valueSelector, matcher) {
compileElementSelector: function compileElementSelector(operand, valueSelector, matcher) {
if (!(0, _Document.isPlainObject)(operand)) {

@@ -894,3 +869,2 @@ throw Error('$elemMatch need an object');

exports.ELEMENT_OPERATORS = ELEMENT_OPERATORS;
// makeLookupFunction(key) returns a lookup function.

@@ -948,3 +922,2 @@ //

// return.
function makeLookupFunction(key, options) {

@@ -961,3 +934,3 @@ options = options || {};

var omitUnnecessaryFields = function (retVal) {
var omitUnnecessaryFields = function omitUnnecessaryFields(retVal) {
if (!retVal.dontIterate) {

@@ -1032,3 +1005,3 @@ delete retVal.dontIterate;

var result = [];
var appendToResult = function (more) {
var appendToResult = function appendToResult(more) {
Array.prototype.push.apply(result, more);

@@ -1058,3 +1031,3 @@ };

if ((0, _Document.isArray)(firstLevel) && !(nextPartIsNumeric && options.forSort)) {
(0, _lodashCollectionEach2['default'])(firstLevel, function (branch, arrayIndex) {
(0, _forEach2.default)(firstLevel, function (branch, arrayIndex) {
if ((0, _Document.isPlainObject)(branch)) {

@@ -1072,3 +1045,3 @@ appendToResult(lookupRest(branch, arrayIndices.concat(arrayIndex)));

var branchesOut = [];
(0, _lodashCollectionEach2['default'])(branches, function (branch) {
(0, _forEach2.default)(branches, function (branch) {
var thisIsArray = (0, _Document.isArray)(branch.value);

@@ -1086,3 +1059,3 @@ // We include the branch itself, *UNLESS* we it's an array that we're going

if (thisIsArray && !branch.dontIterate) {
(0, _lodashCollectionEach2['default'])(branch.value, function (leaf, i) {
(0, _forEach2.default)(branch.value, function (leaf, i) {
branchesOut.push({

@@ -1098,7 +1071,7 @@ value: leaf,

var nothingMatcher = function (docOrBranchedValues) {
var nothingMatcher = function nothingMatcher(docOrBranchedValues) {
return { result: false };
};
var everythingMatcher = function (docOrBranchedValues) {
var everythingMatcher = function everythingMatcher(docOrBranchedValues) {
return { result: true };

@@ -1111,3 +1084,3 @@ };

// the latter it's an array of 'branched values'.
var andSomeMatchers = function (subMatchers) {
var andSomeMatchers = function andSomeMatchers(subMatchers) {
if (subMatchers.length === 0) {

@@ -1122,3 +1095,3 @@ return everythingMatcher;

var ret = {};
ret.result = (0, _lodashCollectionAll2['default'])(subMatchers, function (f) {
ret.result = (0, _every3.default)(subMatchers, function (f) {
var subResult = f(docOrBranches);

@@ -1125,0 +1098,0 @@ // Copy a 'distance' number out of the first sub-matcher that has

'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DocumentModifier = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _checkTypes = require('check-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _checkTypes2 = _interopRequireDefault(_checkTypes);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _assign2 = require('fast.js/object/assign');
var _lodashLangIsObject = require('lodash/lang/isObject');
var _assign3 = _interopRequireDefault(_assign2);
var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
var _forEach = require('fast.js/forEach');
var _lodashObjectAssign = require('lodash/object/assign');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _every2 = require('fast.js/array/every');
var _lodashCollectionEach = require('lodash/collection/each');
var _every3 = _interopRequireDefault(_every2);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashCollectionAll = require('lodash/collection/all');
var _lodashCollectionAll2 = _interopRequireDefault(_lodashCollectionAll);
var _lodashUtilityIdentity = require('lodash/utility/identity');
var _lodashUtilityIdentity2 = _interopRequireDefault(_lodashUtilityIdentity);
var _EJSON = require('./EJSON');

@@ -51,3 +44,9 @@

var DocumentModifier = (function () {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var DocumentModifier = exports.DocumentModifier = (function () {
function DocumentModifier(db) {

@@ -59,3 +58,3 @@ var query = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

this.db = db;
this._matcher = new _DocumentMatcher2['default'](query);
this._matcher = new _DocumentMatcher2.default(query);
this._query = query;

@@ -71,9 +70,9 @@ }

return new _DocumentRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
return new _DocumentRetriver2.default(this.db).retriveForQeury(this._query).then(function (docs) {
var oldResults = [];
var newResults = [];
(0, _lodashCollectionEach2['default'])(docs, function (d) {
(0, _forEach2.default)(docs, function (d) {
var match = _this._matcher.documentMatches(d);
if (match.result) {
var matchOpts = (0, _lodashObjectAssign2['default'])({ arrayIndices: match.arrayIndices }, options);
var matchOpts = (0, _assign3.default)({ arrayIndices: match.arrayIndices }, options);
var newDoc = _this._modifyDocument(d, mod, matchOpts);

@@ -104,2 +103,3 @@ newResults.push(newDoc);

// out when to set the fields in $setOnInsert, if present.
}, {

@@ -115,3 +115,3 @@ key: '_modifyDocument',

// Make sure the caller can't mutate our data structures.
mod = _EJSON2['default'].clone(mod);
mod = _EJSON2.default.clone(mod);

@@ -123,3 +123,3 @@ var isModifier = (0, _Document.isOperatorObject)(mod);

if (!isModifier) {
if (mod._id && !_EJSON2['default'].equals(doc._id, mod._id)) {
if (mod._id && !_EJSON2.default.equals(doc._id, mod._id)) {
throw new Error('Cannot change the _id of a document');

@@ -138,5 +138,5 @@ }

// apply modifiers to the doc.
newDoc = _EJSON2['default'].clone(doc);
newDoc = _EJSON2.default.clone(doc);
(0, _lodashCollectionEach2['default'])(mod, function (operand, op) {
(0, _forEach2.default)(mod, function (operand, op) {
var modFunc = MODIFIERS[op];

@@ -150,3 +150,3 @@ // Treat $setOnInsert as $set if this is an insert.

}
(0, _lodashCollectionEach2['default'])(operand, function (arg, keypath) {
(0, _forEach2.default)(operand, function (arg, keypath) {
if (keypath === '') {

@@ -162,3 +162,5 @@ throw new Error('An empty update path is not valid.');

if (!(0, _lodashCollectionAll2['default'])(keyparts, _lodashUtilityIdentity2['default'])) {
if (!(0, _every3.default)(keyparts, function (x) {
return x;
})) {
throw new Error('The update path \'' + keypath + '\' contains an empty field name, which is not allowed.');

@@ -185,4 +187,3 @@ }

exports.DocumentModifier = DocumentModifier;
exports['default'] = DocumentModifier;
exports.default = DocumentModifier;

@@ -206,3 +207,4 @@ // for a.b.c.2.d.e, keyparts should be ['a', 'b', 'c', '2', 'd', 'e'],

// the path.
var findModTarget = function (doc, keyparts, options) {
var findModTarget = function findModTarget(doc, keyparts, options) {
options = options || {};

@@ -256,3 +258,3 @@ var usedArrayIndex = false;

doc.push({});
} else if (typeof doc[keypart] !== 'object') {
} else if (_typeof(doc[keypart]) !== 'object') {
throw new Error('can\'t modify field \'' + keyparts[i + 1] + '\' of list value ' + JSON.stringify(doc[keypart]));

@@ -293,3 +295,3 @@ }

var MODIFIERS = {
$inc: function (target, field, arg) {
$inc: function $inc(target, field, arg) {
if (typeof arg !== 'number') {

@@ -307,5 +309,4 @@ throw new Error('Modifier $inc allowed for numbers only');

},
$set: function (target, field, arg) {
if (!(0, _lodashLangIsObject2['default'])(target)) {
// not an array or an object
$set: function $set(target, field, arg) {
if (!_checkTypes2.default.object(target) && !_checkTypes2.default.array(target)) {
var e = new Error('Cannot set property on non-object field');

@@ -322,6 +323,6 @@ e.setPropertyError = true;

},
$setOnInsert: function (target, field, arg) {
$setOnInsert: function $setOnInsert(target, field, arg) {
// converted to `$set` in `_modify`
},
$unset: function (target, field, arg) {
$unset: function $unset(target, field, arg) {
if (target !== undefined) {

@@ -337,3 +338,3 @@ if (target instanceof Array) {

},
$push: function (target, field, arg) {
$push: function $push(target, field, arg) {
if (target[field] === undefined) {

@@ -394,3 +395,3 @@ target[field] = [];

// XXX is it correct that we don't do geo-stuff here?
sortFunction = new _DocumentSorter2['default'](arg.$sort).getComparator();
sortFunction = new _DocumentSorter2.default(arg.$sort).getComparator();
for (var i = 0; i < toPush.length; i++) {

@@ -430,4 +431,4 @@ if (_Document.MongoTypeComp._type(toPush[i]) !== 3) {

},
$pushAll: function (target, field, arg) {
if (!(typeof arg === 'object' && arg instanceof Array)) {
$pushAll: function $pushAll(target, field, arg) {
if (!((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && arg instanceof Array)) {
throw new Error('Modifier $pushAll/pullAll allowed for arrays only');

@@ -446,5 +447,5 @@ }

},
$addToSet: function (target, field, arg) {
$addToSet: function $addToSet(target, field, arg) {
var isEach = false;
if (typeof arg === 'object') {
if ((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object') {
//check if first key is '$each'

@@ -465,3 +466,3 @@ for (var k in arg) {

} else {
(0, _lodashCollectionEach2['default'])(values, function (value) {
(0, _forEach2.default)(values, function (value) {
for (var i = 0; i < x.length; i++) {

@@ -476,3 +477,3 @@ if (_Document.MongoTypeComp._equal(value, x[i])) {

},
$pop: function (target, field, arg) {
$pop: function $pop(target, field, arg) {
if (target === undefined) {

@@ -494,3 +495,3 @@ return;

},
$pull: function (target, field, arg) {
$pull: function $pull(target, field, arg) {
if (target === undefined) {

@@ -506,3 +507,3 @@ return;

var out = [];
if (arg != null && typeof arg === 'object' && !(arg instanceof Array)) {
if (arg != null && (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && !(arg instanceof Array)) {
// XXX would be much nicer to compile this once, rather than

@@ -517,3 +518,3 @@ // for each document we modify.. but usually we're not

// same issue as $elemMatch possibly?
var matcher = new _DocumentMatcher2['default'](arg);
var matcher = new _DocumentMatcher2.default(arg);
for (var i = 0; i < x.length; i++) {

@@ -534,4 +535,4 @@ if (!matcher.documentMatches(x[i]).result) {

},
$pullAll: function (target, field, arg) {
if (!(typeof arg === 'object' && arg instanceof Array)) {
$pullAll: function $pullAll(target, field, arg) {
if (!((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object' && arg instanceof Array)) {
throw new Error('Modifier $pushAll/pullAll allowed for arrays only');

@@ -564,3 +565,3 @@ }

},
$rename: function (target, field, arg, keypath, doc) {
$rename: function $rename(target, field, arg, keypath, doc) {
if (keypath === arg) {

@@ -590,3 +591,3 @@ // no idea why mongo has this restriction..

},
$bit: function (target, field, arg) {
$bit: function $bit(target, field, arg) {
// XXX mongo only supports $bit on integers, and we only support

@@ -593,0 +594,0 @@ // native javascript numbers (doubles) so far, so we can't support $bit

'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DocumentRetriver = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _checkTypes = require('check-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _checkTypes2 = _interopRequireDefault(_checkTypes);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _keys2 = require('fast.js/object/keys');
var _lodashLangIsObject = require('lodash/lang/isObject');
var _keys3 = _interopRequireDefault(_keys2);
var _lodashLangIsObject2 = _interopRequireDefault(_lodashLangIsObject);
var _map2 = require('fast.js/map');
var _lodashLangIsArray = require('lodash/lang/isArray');
var _map3 = _interopRequireDefault(_map2);
var _lodashLangIsArray2 = _interopRequireDefault(_lodashLangIsArray);
var _Document = require('./Document');
var _lodashObjectHas = require('lodash/object/has');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _lodashCollectionSize = require('lodash/collection/size');
var _lodashCollectionSize2 = _interopRequireDefault(_lodashCollectionSize);
var _Document = require('./Document');
/**

@@ -39,3 +36,3 @@ * Class for getting data objects by given list of ids.

var DocumentRetriver = (function () {
var DocumentRetriver = exports.DocumentRetriver = (function () {
function DocumentRetriver(db) {

@@ -65,3 +62,3 @@ _classCallCheck(this, DocumentRetriver);

selectorIds = [query._id];
} else if ((0, _lodashLangIsObject2['default'])(query) && (0, _lodashObjectHas2['default'])(query, '_id') && (0, _lodashLangIsObject2['default'])(query._id) && (0, _lodashObjectHas2['default'])(query._id, '$in') && (0, _lodashLangIsArray2['default'])(query._id.$in)) {
} else if (_checkTypes2.default.object(query) && query.hasOwnProperty('_id') && _checkTypes2.default.object(query._id) && query._id.hasOwnProperty('$in') && _checkTypes2.default.array(query._id.$in)) {
// and finally fast path for multiple ids

@@ -73,3 +70,3 @@ // selected by $in operator

// Retrive optimally
if ((0, _lodashCollectionSize2['default'])(selectorIds) > 0) {
if (_checkTypes2.default.object(selectorIds) && (0, _keys3.default)(selectorIds).length > 0) {
return this.retriveIds(selectorIds);

@@ -86,2 +83,3 @@ } else {

*/
}, {

@@ -108,2 +106,3 @@ key: 'retriveAll',

*/
}, {

@@ -114,3 +113,3 @@ key: 'retriveIds',

var retrPromises = ids.map(function (id) {
var retrPromises = (0, _map3.default)(ids, function (id) {
return _this2.retriveOne(id);

@@ -126,2 +125,3 @@ });

*/
}, {

@@ -141,3 +141,2 @@ key: 'retriveOne',

exports.DocumentRetriver = DocumentRetriver;
exports['default'] = DocumentRetriver;
exports.default = DocumentRetriver;
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DocumentSorter = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _checkTypes = require('check-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _checkTypes2 = _interopRequireDefault(_checkTypes);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _forEach = require('fast.js/forEach');
var _lodashLangIsEmpty = require('lodash/lang/isEmpty');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
var _every2 = require('fast.js/array/every');
var _lodashObjectHas = require('lodash/object/has');
var _every3 = _interopRequireDefault(_every2);
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
var _map2 = require('fast.js/map');
var _lodashCollectionEach = require('lodash/collection/each');
var _map3 = _interopRequireDefault(_map2);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _indexOf2 = require('fast.js/array/indexOf');
var _lodashCollectionContains = require('lodash/collection/contains');
var _indexOf3 = _interopRequireDefault(_indexOf2);
var _lodashCollectionContains2 = _interopRequireDefault(_lodashCollectionContains);
var _keys2 = require('fast.js/object/keys');
var _lodashCollectionAll = require('lodash/collection/all');
var _keys3 = _interopRequireDefault(_keys2);
var _lodashCollectionAll2 = _interopRequireDefault(_lodashCollectionAll);
var _DocumentMatcher = require('./DocumentMatcher');
var _lodashCollectionSize = require('lodash/collection/size');
var _DocumentMatcher2 = _interopRequireDefault(_DocumentMatcher);
var _lodashCollectionSize2 = _interopRequireDefault(_lodashCollectionSize);
var _Document = require('./Document');
var _lodashCollectionMap = require('lodash/collection/map');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
var _lodashCollectionPluck = require('lodash/collection/pluck');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _lodashCollectionPluck2 = _interopRequireDefault(_lodashCollectionPluck);
var _DocumentMatcher = require('./DocumentMatcher');
var _DocumentMatcher2 = _interopRequireDefault(_DocumentMatcher);
var _Document = require('./Document');
// Give a sort spec, which can be in any of these forms:

@@ -64,3 +59,3 @@ // {'key1': 1, 'key2': -1}

var DocumentSorter = (function () {
var DocumentSorter = exports.DocumentSorter = (function () {
function DocumentSorter(spec) {

@@ -75,3 +70,3 @@ var _this = this;

var addSpecPart = function (path, ascending) {
var addSpecPart = function addSpecPart(path, ascending) {
if (!path) {

@@ -98,4 +93,4 @@ throw Error('sort keys must be non-empty');

}
} else if (typeof spec === 'object') {
(0, _lodashCollectionEach2['default'])(spec, function (value, key) {
} else if ((typeof spec === 'undefined' ? 'undefined' : _typeof(spec)) === 'object') {
(0, _forEach2.default)(spec, function (value, key) {
addSpecPart(key, value >= 0);

@@ -112,9 +107,9 @@ });

var selector = {};
(0, _lodashCollectionEach2['default'])(this._sortSpecParts, function (nextSpec) {
(0, _forEach2.default)(this._sortSpecParts, function (nextSpec) {
selector[nextSpec.path] = 1;
});
this._selectorForAffectedByModifier = new _DocumentMatcher2['default'](selector);
this._selectorForAffectedByModifier = new _DocumentMatcher2.default(selector);
}
this._keyComparator = composeComparators((0, _lodashCollectionMap2['default'])(this._sortSpecParts, function (nextSpec, j) {
this._keyComparator = composeComparators((0, _map3.default)(this._sortSpecParts, function (nextSpec, j) {
return _this._keyFieldComparator(j);

@@ -158,3 +153,5 @@ }));

value: function _getPaths() {
return (0, _lodashCollectionPluck2['default'])(this._sortSpecParts, 'path');
return (0, _map3.default)(this._sortSpecParts, function (x) {
return x.path;
});
}

@@ -172,2 +169,3 @@

// [1,3], and the minimum key is [0,5]; notably, [0,3] is NOT a key.
}, {

@@ -209,2 +207,3 @@ key: '_getMinKeyFromDoc',

// 'cb' with the key.
}, {

@@ -220,3 +219,3 @@ key: '_generateKeysFromDoc',

var pathFromIndices = function (indices) {
var pathFromIndices = function pathFromIndices(indices) {
return indices.join(',') + ',';

@@ -227,3 +226,3 @@ };

(0, _lodashCollectionEach2['default'])(this._sortSpecParts, function (spec, whichField) {
(0, _forEach2.default)(this._sortSpecParts, function (spec, whichField) {
// Expand any leaf arrays that we find, and ignore those arrays

@@ -241,3 +240,3 @@ // themselves. (We never sort based on an array itself.)

valuesByIndexAndPath[whichField] = {};
(0, _lodashCollectionEach2['default'])(branches, function (branch) {
(0, _forEach2.default)(branches, function (branch) {
if (!branch.arrayIndices) {

@@ -256,3 +255,3 @@ // If there are no array indices for a branch, then it must be the

var path = pathFromIndices(branch.arrayIndices);
if ((0, _lodashObjectHas2['default'])(valuesByIndexAndPath[whichField], path)) {
if (valuesByIndexAndPath[whichField].hasOwnProperty(path)) {
throw Error('duplicate path: ' + path);

@@ -272,3 +271,3 @@ }

// XXX achieve full compatibility here
if (knownPaths && !(0, _lodashObjectHas2['default'])(knownPaths, path)) {
if (knownPaths && !knownPaths.hasOwnProperty(path)) {
throw Error('cannot index parallel arrays');

@@ -281,3 +280,3 @@ }

// non-array field.
if (!(0, _lodashObjectHas2['default'])(valuesByIndexAndPath[whichField], '') && (0, _lodashCollectionSize2['default'])(knownPaths) !== (0, _lodashCollectionSize2['default'])(valuesByIndexAndPath[whichField])) {
if (!valuesByIndexAndPath[whichField].hasOwnProperty('') && (0, _keys3.default)(knownPaths).length !== (0, _keys3.default)(valuesByIndexAndPath[whichField]).length) {
throw Error('cannot index parallel arrays!');

@@ -287,3 +286,3 @@ }

knownPaths = {};
(0, _lodashCollectionEach2['default'])(valuesByIndexAndPath[whichField], function (x, path) {
(0, _forEach2.default)(valuesByIndexAndPath[whichField], function (x, path) {
knownPaths[path] = true;

@@ -296,4 +295,4 @@ });

// Easy case: no use of arrays.
var soleKey = (0, _lodashCollectionMap2['default'])(valuesByIndexAndPath, function (values) {
if (!(0, _lodashObjectHas2['default'])(values, '')) {
var soleKey = (0, _map3.default)(valuesByIndexAndPath, function (values) {
if (!values.hasOwnProperty('')) {
throw Error('no value in sole key case?');

@@ -307,8 +306,8 @@ }

(0, _lodashCollectionEach2['default'])(knownPaths, function (x, path) {
var key = (0, _lodashCollectionMap2['default'])(valuesByIndexAndPath, function (values) {
if ((0, _lodashObjectHas2['default'])(values, '')) {
(0, _forEach2.default)(knownPaths, function (x, path) {
var key = (0, _map3.default)(valuesByIndexAndPath, function (values) {
if (values.hasOwnProperty('')) {
return values[''];
}
if (!(0, _lodashObjectHas2['default'])(values, path)) {
if (!values.hasOwnProperty(path)) {
throw Error('missing path?');

@@ -325,2 +324,3 @@ }

// compare fields.
}, {

@@ -338,2 +338,3 @@ key: '_compareKeys',

// on field 'i'.
}, {

@@ -354,2 +355,3 @@ key: '_keyFieldComparator',

// including a possible geoquery distance tie-breaker).
}, {

@@ -394,2 +396,3 @@ key: '_getBaseComparator',

// on our understanding of Mongo's behavior.
}, {

@@ -405,3 +408,3 @@ key: '_useWithMatcher',

// XXX figure out how geoqueries interact with this stuff
if ((0, _lodashLangIsEmpty2['default'])(this._sortSpecParts)) {
if (_checkTypes2.default.emptyArray(this._sortSpecParts)) {
return;

@@ -419,7 +422,7 @@ }

var constraintsByPath = {};
(0, _lodashCollectionEach2['default'])(this._sortSpecParts, function (spec, i) {
(0, _forEach2.default)(this._sortSpecParts, function (spec, i) {
constraintsByPath[spec.path] = [];
});
(0, _lodashCollectionEach2['default'])(selector, function (subSelector, key) {
(0, _forEach2.default)(selector, function (subSelector, key) {
// XXX support $and and $or

@@ -451,4 +454,4 @@

if ((0, _Document.isOperatorObject)(subSelector)) {
(0, _lodashCollectionEach2['default'])(subSelector, function (operand, operator) {
if ((0, _lodashCollectionContains2['default'])(['$lt', '$lte', '$gt', '$gte'], operator)) {
(0, _forEach2.default)(subSelector, function (operand, operator) {
if ((0, _indexOf3.default)(['$lt', '$lte', '$gt', '$gte'], operator) >= 0) {
// XXX this depends on us knowing that these operators don't use any

@@ -477,3 +480,4 @@ // of the arguments to compileElementSelector other than operand.

// or not as we wish.
if ((0, _lodashLangIsEmpty2['default'])(constraintsByPath[this._sortSpecParts[0].path])) {
var currConstraint = constraintsByPath[this._sortSpecParts[0].path];
if (!_checkTypes2.default.assigned(currConstraint) || _checkTypes2.default.emptyArray(currConstraint)) {
return;

@@ -483,4 +487,4 @@ }

this._keyFilter = function (key) {
return (0, _lodashCollectionAll2['default'])(this._sortSpecParts, function (specPart, index) {
return (0, _lodashCollectionAll2['default'])(constraintsByPath[specPart.path], function (f) {
return (0, _every3.default)(this._sortSpecParts, function (specPart, index) {
return (0, _every3.default)(constraintsByPath[specPart.path], function (f) {
return f(key[index]);

@@ -496,4 +500,3 @@ });

exports.DocumentSorter = DocumentSorter;
exports['default'] = DocumentSorter;
exports.default = DocumentSorter;

@@ -504,3 +507,4 @@ // Given an array of comparators

// non-zero value.
var composeComparators = function (comparatorArray) {
var composeComparators = function composeComparators(comparatorArray) {
return function (a, b) {

@@ -507,0 +511,0 @@ for (var i = 0; i < comparatorArray.length; ++i) {

@@ -1,52 +0,55 @@

/**
* Based on Meteor's EJSON package.
* Rewrite with ES6 and better formated for passing
* linter
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EJSON = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _Base = require('./Base64');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _Base2 = _interopRequireDefault(_Base);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _some2 = require('fast.js/array/some');
var _Base64 = require('./Base64');
var _some3 = _interopRequireDefault(_some2);
var _Base642 = _interopRequireDefault(_Base64);
var _checkTypes = require('check-types');
var _lodashLangIsEmpty = require('lodash/lang/isEmpty');
var _checkTypes2 = _interopRequireDefault(_checkTypes);
var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
var _keys2 = require('fast.js/object/keys');
var _lodashLangIsNaN = require('lodash/lang/isNaN');
var _keys3 = _interopRequireDefault(_keys2);
var _lodashLangIsNaN2 = _interopRequireDefault(_lodashLangIsNaN);
var _forEach = require('fast.js/forEach');
var _lodashLangIsArguments = require('lodash/lang/isArguments');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashLangIsArguments2 = _interopRequireDefault(_lodashLangIsArguments);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _lodashObjectHas = require('lodash/object/has');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } /**
* Based on Meteor's EJSON package.
* Rewrite with ES6 and better formated for passing
* linter
*/
var _lodashObjectKeys = require('lodash/object/keys');
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _lodashCollectionEach = require('lodash/collection/each');
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
// Internal utils
function isInfOrNan(val) {
return (0, _lodashLangIsNaN2['default'])(val) || val === Infinity || val === -Infinity;
function _isNaN(val) {
return typeof val === 'number' && val != +val;
}
function _has(obj, key) {
return _checkTypes2.default.object(obj) && obj.hasOwnProperty(key);
}
function _isInfOrNan(val) {
return _isNaN(val) || val === Infinity || val === -Infinity;
}
function _isArguments(val) {
return !!val && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) == 'object' && Object.prototype.hasOwnProperty.call(val, 'callee') && !Object.prototype.propertyIsEnumerable.call(val, 'callee');
}
var EJSON = (function () {
var EJSON = exports.EJSON = (function () {
// @ngInject

@@ -81,3 +84,3 @@

value: function addType(name, factory) {
if ((0, _lodashObjectHas2['default'])(this._customTypes, name)) {
if (_has(this._customTypes, name)) {
throw new Error('Type ' + name + ' already present');

@@ -93,2 +96,3 @@ }

*/
}, {

@@ -101,3 +105,3 @@ key: 'toJSONValue',

}
if (typeof item === 'object') {
if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object') {
item = this.clone(item);

@@ -114,2 +118,3 @@ this._adjustTypesToJSONValue(item);

*/
}, {

@@ -119,3 +124,3 @@ key: 'fromJSONValue',

var changed = this._fromJSONValueHelper(item);
if (changed === item && typeof item === 'object') {
if (changed === item && (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object') {
item = this.clone(item);

@@ -135,2 +140,3 @@ this._adjustTypesFromJSONValue(item);

*/
}, {

@@ -148,2 +154,3 @@ key: 'stringify',

*/
}, {

@@ -163,2 +170,3 @@ key: 'parse',

*/
}, {

@@ -178,2 +186,3 @@ key: 'isBinary',

*/
}, {

@@ -189,3 +198,3 @@ key: 'equals',

}
if ((0, _lodashLangIsNaN2['default'])(a) && (0, _lodashLangIsNaN2['default'])(b)) {
if (_isNaN(a) && _isNaN(b)) {
return true; // This differs from the IEEE spec for NaN equality, b/c we don't want

@@ -198,3 +207,3 @@ // anything ever with a NaN to be poisoned from becoming equal to anything.

}
if (!(typeof a === 'object' && typeof b === 'object')) {
if (!((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object' && (typeof b === 'undefined' ? 'undefined' : _typeof(b)) === 'object')) {
return false;

@@ -246,5 +255,5 @@ }

if (keyOrderSensitive) {
var bKeys = (0, _lodashObjectKeys2['default'])(b);
var bKeys = (0, _keys3.default)(b);
i = 0;
ret = (0, _lodashObjectKeys2['default'])(a).every(function (x) {
ret = (0, _keys3.default)(a).every(function (x) {
if (i >= bKeys.length) {

@@ -265,4 +274,4 @@ return false;

i = 0;
ret = (0, _lodashObjectKeys2['default'])(a).every(function (key) {
if (!(0, _lodashObjectHas2['default'])(b, key)) {
ret = (0, _keys3.default)(a).every(function (key) {
if (!_has(b, key)) {
return false;

@@ -276,3 +285,3 @@ }

});
return ret && (0, _lodashObjectKeys2['default'])(b).length === i;
return ret && (0, _keys3.default)(b).length === i;
}

@@ -286,2 +295,3 @@ }

*/
}, {

@@ -293,3 +303,3 @@ key: 'clone',

var ret;
if (typeof v !== 'object') {
if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) !== 'object') {
return v;

@@ -309,3 +319,3 @@ }

if (this.isBinary(v)) {
ret = _Base642['default'].newBinary(v.length);
ret = _Base2.default.newBinary(v.length);
for (var i = 0; i < v.length; i++) {

@@ -317,3 +327,3 @@ ret[i] = v[i];

if (Array.isArray(v) || (0, _lodashLangIsArguments2['default'])(v)) {
if (_checkTypes2.default.array(v) || _isArguments(v)) {
ret = [];

@@ -335,3 +345,3 @@ for (var i = 0; i < v.length; i++) {

ret = {};
(0, _lodashCollectionEach2['default'])(v, function (val, key) {
(0, _forEach2.default)(v, function (val, key) {
ret[key] = _this2.clone(val);

@@ -344,3 +354,3 @@ });

value: function newBinary(len) {
return _Base642['default'].newBinary(len);
return _Base2.default.newBinary(len);
}

@@ -353,12 +363,12 @@ }, {

this._builtinConverters = [{ // Date
matchJSONValue: function (obj) {
return (0, _lodashObjectHas2['default'])(obj, '$date') && (0, _lodashObjectKeys2['default'])(obj).length === 1;
matchJSONValue: function matchJSONValue(obj) {
return _has(obj, '$date') && (0, _keys3.default)(obj).length === 1;
},
matchObject: function (obj) {
matchObject: function matchObject(obj) {
return obj instanceof Date;
},
toJSONValue: function (obj) {
toJSONValue: function toJSONValue(obj) {
return { $date: obj.getTime() };
},
fromJSONValue: function (obj) {
fromJSONValue: function fromJSONValue(obj) {
return new Date(obj.$date);

@@ -368,9 +378,9 @@ }

// which we match.)
matchJSONValue: function (obj) {
return (0, _lodashObjectHas2['default'])(obj, '$InfNaN') && (0, _lodashObjectKeys2['default'])(obj).length === 1;
matchJSONValue: function matchJSONValue(obj) {
return _has(obj, '$InfNaN') && (0, _keys3.default)(obj).length === 1;
},
matchObject: isInfOrNan,
toJSONValue: function (obj) {
matchObject: _isInfOrNan,
toJSONValue: function toJSONValue(obj) {
var sign;
if ((0, _lodashLangIsNaN2['default'])(obj)) {
if (_isNaN(obj)) {
sign = 0;

@@ -384,33 +394,33 @@ } else if (obj === Infinity) {

},
fromJSONValue: function (obj) {
fromJSONValue: function fromJSONValue(obj) {
return obj.$InfNaN / 0;
}
}, { // Binary
matchJSONValue: function (obj) {
return (0, _lodashObjectHas2['default'])(obj, '$binary') && (0, _lodashObjectKeys2['default'])(obj).length === 1;
matchJSONValue: function matchJSONValue(obj) {
return _has(obj, '$binary') && (0, _keys3.default)(obj).length === 1;
},
matchObject: function (obj) {
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && (0, _lodashObjectHas2['default'])(obj, '$Uint8ArrayPolyfill');
matchObject: function matchObject(obj) {
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && _has(obj, '$Uint8ArrayPolyfill');
},
toJSONValue: function (obj) {
return { $binary: _Base642['default'].encode(obj) };
toJSONValue: function toJSONValue(obj) {
return { $binary: _Base2.default.encode(obj) };
},
fromJSONValue: function (obj) {
return _Base642['default'].decode(obj.$binary);
fromJSONValue: function fromJSONValue(obj) {
return _Base2.default.decode(obj.$binary);
}
}, { // Escaping one level
matchJSONValue: function (obj) {
return (0, _lodashObjectHas2['default'])(obj, '$escape') && (0, _lodashObjectKeys2['default'])(obj).length === 1;
matchJSONValue: function matchJSONValue(obj) {
return _has(obj, '$escape') && (0, _keys3.default)(obj).length === 1;
},
matchObject: function (obj) {
if ((0, _lodashLangIsEmpty2['default'])(obj) || (0, _lodashObjectKeys2['default'])(obj).length > 2) {
matchObject: function matchObject(obj) {
if (!_checkTypes2.default.assigned(obj) || _checkTypes2.default.emptyObject(obj) || _checkTypes2.default.object(obj) && (0, _keys3.default)(obj).length > 2) {
return false;
}
return _this3._builtinConverters.some(function (converter) {
return (0, _some3.default)(_this3._builtinConverters, function (converter) {
return converter.matchJSONValue(obj);
});
},
toJSONValue: function (obj) {
toJSONValue: function toJSONValue(obj) {
var newObj = {};
(0, _lodashCollectionEach2['default'])(obj, function (val, key) {
(0, _forEach2.default)(obj, function (val, key) {
newObj[key] = _this3.toJSONValue(val);

@@ -420,5 +430,5 @@ });

},
fromJSONValue: function (obj) {
fromJSONValue: function fromJSONValue(obj) {
var newObj = {};
(0, _lodashCollectionEach2['default'])(obj.$escape, function (val, key) {
(0, _forEach2.default)(obj.$escape, function (val, key) {
newObj[key] = _this3.fromJSONValue(val);

@@ -429,15 +439,15 @@ });

}, { // Custom
matchJSONValue: function (obj) {
return (0, _lodashObjectHas2['default'])(obj, '$type') && (0, _lodashObjectHas2['default'])(obj, '$value') && (0, _lodashObjectKeys2['default'])(obj).length === 2;
matchJSONValue: function matchJSONValue(obj) {
return _has(obj, '$type') && _has(obj, '$value') && (0, _keys3.default)(obj).length === 2;
},
matchObject: function (obj) {
matchObject: function matchObject(obj) {
return _this3._isCustomType(obj);
},
toJSONValue: function (obj) {
toJSONValue: function toJSONValue(obj) {
var jsonValue = obj.toJSONValue();
return { $type: obj.typeName(), $value: jsonValue };
},
fromJSONValue: function (obj) {
fromJSONValue: function fromJSONValue(obj) {
var typeName = obj.$type;
if (!(0, _lodashObjectHas2['default'])(_this3._customTypes, typeName)) {
if (!_has(_this3._customTypes, typeName)) {
throw new Error('Custom EJSON type ' + typeName + ' is not defined');

@@ -453,3 +463,3 @@ }

value: function _isCustomType(obj) {
return obj && typeof obj.toJSONValue === 'function' && typeof obj.typeName === 'function' && (0, _lodashObjectHas2['default'])(this._customTypes, obj.typeName());
return obj && typeof obj.toJSONValue === 'function' && typeof obj.typeName === 'function' && _has(this._customTypes, obj.typeName());
}

@@ -460,2 +470,3 @@

*/
}, {

@@ -476,3 +487,3 @@ key: '_adjustTypesToJSONValue',

// Other atoms are unchanged.
if (typeof obj !== 'object') {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
return obj;

@@ -482,4 +493,4 @@ }

// Iterate over array or object structure.
(0, _lodashCollectionEach2['default'])(obj, function (value, key) {
if (typeof value !== 'object' && value !== undefined && !isInfOrNan(value)) {
(0, _forEach2.default)(obj, function (value, key) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' && value !== undefined && !_isInfOrNan(value)) {
return;

@@ -504,2 +515,3 @@ }

*/
}, {

@@ -522,2 +534,3 @@ key: '_toJSONValueHelper',

*/
}, {

@@ -537,8 +550,8 @@ key: '_adjustTypesFromJSONValue',

// Other atoms are unchanged.
if (typeof obj !== 'object') {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
return obj;
}
(0, _lodashCollectionEach2['default'])(obj, function (value, key) {
if (typeof value === 'object') {
(0, _forEach2.default)(obj, function (value, key) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
var changed = _this5._fromJSONValueHelper(value);

@@ -563,7 +576,8 @@ if (value !== changed) {

*/
}, {
key: '_fromJSONValueHelper',
value: function _fromJSONValueHelper(value) {
if (typeof value === 'object' && value !== null) {
if ((0, _lodashObjectKeys2['default'])(value).length <= 2 && (0, _lodashObjectKeys2['default'])(value).every(function (k) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null) {
if ((0, _keys3.default)(value).length <= 2 && (0, _keys3.default)(value).every(function (k) {
return typeof k === 'string' && k.substr(0, 1) === '$';

@@ -586,3 +600,2 @@ })) {

exports.EJSON = EJSON;
exports['default'] = new EJSON();
exports.default = new EJSON();
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.IndexManager = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _keys2 = require('fast.js/object/keys');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _keys3 = _interopRequireDefault(_keys2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _forEach = require('fast.js/forEach');
var _lodashObjectKeys = require('lodash/object/keys');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _map2 = require('fast.js/map');
var _map3 = _interopRequireDefault(_map2);
var _invariant = require('invariant');

@@ -21,2 +26,6 @@

var _PromiseQueue = require('./PromiseQueue');
var _PromiseQueue2 = _interopRequireDefault(_PromiseQueue);
var _CollectionIndex = require('./CollectionIndex');

@@ -30,5 +39,5 @@

var _PromiseQueue = require('./PromiseQueue');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _PromiseQueue2 = _interopRequireDefault(_PromiseQueue);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -42,3 +51,3 @@ /**

var IndexManager = (function () {
var IndexManager = exports.IndexManager = (function () {
function IndexManager(db) {

@@ -51,5 +60,3 @@ var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

this.indexes = {};
this._queue = new _PromiseQueue2['default']({
concurrency: options.concurrency || 2
});
this._queue = new _PromiseQueue2.default(options.concurrency || 2);

@@ -80,7 +87,7 @@ // By default ensure index by _id field

value: function ensureIndex(options) {
(0, _invariant2['default'])(options && options.fieldName, 'You must specify a fieldName in options object');
(0, _invariant2.default)(options && options.fieldName, 'You must specify a fieldName in options object');
var key = options.fieldName;
if (!this.indexes[key]) {
this.indexes[key] = new _CollectionIndex2['default'](options);
this.indexes[key] = new _CollectionIndex2.default(options);
return this.buildIndex(key);

@@ -103,2 +110,3 @@ } else if (this.indexes[key].buildPromise) {

*/
}, {

@@ -109,8 +117,8 @@ key: 'buildIndex',

(0, _invariant2['default'])(this.indexes[key], 'Index with key `%s` does not ensured yet', key);
(0, _invariant2.default)(this.indexes[key], 'Index with key `%s` does not ensured yet', key);
var cleanup = function () {
var cleanup = function cleanup() {
return _this.indexes[key].buildPromise = null;
};
var buildPromise = this._queue.push(this._doBuildIndex.bind(this, key), 10).then(cleanup, cleanup);
var buildPromise = this._queue.add(this._doBuildIndex.bind(this, key)).then(cleanup, cleanup);

@@ -127,2 +135,3 @@ this.indexes[key].buildPromise = buildPromise;

*/
}, {

@@ -133,3 +142,3 @@ key: 'buildAllIndexes',

return Promise.all((0, _lodashObjectKeys2['default'])(this.indexes).map(function (k) {
return Promise.all((0, _map3.default)((0, _keys3.default)(this.indexes), function (k) {
return _this2.ensureIndex({

@@ -147,2 +156,3 @@ fieldName: k,

*/
}, {

@@ -153,6 +163,5 @@ key: 'removeIndex',

return this._queue.push(function (resolve, reject) {
return this._queue.add(function () {
delete _this3.indexes[key];
resolve();
}, 10);
});
}

@@ -165,2 +174,3 @@

*/
}, {

@@ -171,18 +181,17 @@ key: 'indexDocument',

return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this4.indexes);
return this._queue.add(function () {
var keys = (0, _keys3.default)(_this4.indexes);
var failingIndex = null;
try {
keys.forEach(function (k, i) {
(0, _forEach2.default)(keys, function (k, i) {
failingIndex = i;
_this4.indexes[k].insert(doc);
});
resolve();
} catch (e) {
keys.slice(0, failingIndex).forEach(function (k) {
(0, _forEach2.default)(keys.slice(0, failingIndex), function (k) {
_this4.indexes[k].remove(doc);
});
reject(e);
throw e;
}
}, 1);
});
}

@@ -197,2 +206,3 @@

*/
}, {

@@ -203,18 +213,17 @@ key: 'reindexDocument',

return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this5.indexes);
return this._queue.add(function () {
var keys = (0, _keys3.default)(_this5.indexes);
var failingIndex = null;
try {
keys.forEach(function (k, i) {
(0, _forEach2.default)(keys, function (k, i) {
failingIndex = i;
_this5.indexes[k].update(oldDoc, newDoc);
});
resolve();
} catch (e) {
keys.slice(0, failingIndex).forEach(function (k) {
(0, _forEach2.default)(keys.slice(0, failingIndex), function (k) {
_this5.indexes[k].revertUpdate(oldDoc, newDoc);
});
reject(e);
throw e;
}
}, 1);
});
}

@@ -227,2 +236,3 @@

*/
}, {

@@ -233,9 +243,8 @@ key: 'deindexDocument',

return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this6.indexes);
keys.forEach(function (k) {
return this._queue.add(function () {
var keys = (0, _keys3.default)(_this6.indexes);
(0, _forEach2.default)(keys, function (k) {
_this6.indexes[k].remove(doc);
});
resolve();
}, 1);
});
}

@@ -248,5 +257,6 @@

*/
}, {
key: '_doBuildIndex',
value: function _doBuildIndex(key, resolve, reject) {
value: function _doBuildIndex(key) {
// Get and reset index

@@ -258,4 +268,4 @@ var index = this.indexes[key];

var errors = [];
new _DocumentRetriver2['default'](this.db).retriveAll().then(function (docs) {
docs.forEach(function (doc) {
return new _DocumentRetriver2.default(this.db).retriveAll().then(function (docs) {
(0, _forEach2.default)(docs, function (doc) {
try {

@@ -268,6 +278,4 @@ index.insert(doc);

if (errors.length) {
resolve();
} else {
reject(errors);
if (errors.length > 0) {
throw new Error('Index build failed with errors: ', errors);
}

@@ -281,3 +289,2 @@ });

exports.IndexManager = IndexManager;
exports['default'] = IndexManager;
exports.default = IndexManager;
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Queue;
/**
* @return {Object}
*/
var LocalPromise = typeof Promise !== 'undefined' ? Promise : function () {
return {
then: function then() {
throw new Error('Queue.configure() before use Queue');
}
};
};
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var noop = function noop() {};
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/**
* @param {*} value
* @returns {LocalPromise}
*/
var resolveWith = function resolveWith(value) {
if (value && typeof value.then === 'function') {
return value;
}
var _async = require('async');
return new LocalPromise(function (resolve) {
resolve(value);
});
};
/**
* Queue that resolves a Promise when task
* is done or rejected if errored.
* It limits concurrently executed promises
*
* @param {Number} [maxPendingPromises=Infinity] max number of concurrently executed promises
* @param {Number} [maxQueuedPromises=Infinity] max number of queued promises
* @constructor
*
* @example
*
* var queue = new Queue(1);
*
* queue.add(function () {
* // resolve of this promise will resume next request
* return downloadTarballFromGithub(url, file);
* })
* .then(function (file) {
* doStuffWith(file);
* });
*
* queue.add(function () {
* return downloadTarballFromGithub(url, file);
* })
* // This request will be paused
* .then(function (file) {
* doStuffWith(file);
* });
*/
function Queue(maxPendingPromises, maxQueuedPromises) {
this.pendingPromises = 0;
this.maxPendingPromises = typeof maxPendingPromises !== 'undefined' ? maxPendingPromises : Infinity;
this.maxQueuedPromises = typeof maxQueuedPromises !== 'undefined' ? maxQueuedPromises : Infinity;
this.queue = [];
}
var PromiseQueue = (function () {
function PromiseQueue() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
/**
* Defines promise promiseFactory
* @param {Function} GlobalPromise
*/
Queue.configure = function (GlobalPromise) {
LocalPromise = GlobalPromise;
};
_classCallCheck(this, PromiseQueue);
/**
* @param {Function} promiseGenerator
* @return {LocalPromise}
*/
Queue.prototype.add = function (promiseGenerator) {
var self = this;
return new LocalPromise(function (resolve, reject, notify) {
// Do not queue to much promises
if (self.queue.length >= self.maxQueuedPromises) {
reject(new Error('Queue limit reached'));
return;
}
this._queue = (0, _async.queue)(this._operationWorker.bind(this), options.concurrency || 1);
// Add to queue
self.queue.push({
promiseGenerator: promiseGenerator,
resolve: resolve,
reject: reject,
notify: notify || noop
});
self._dequeue();
});
};
/**
* Number of simultaneously running promises (which are resolving)
*
* @return {number}
*/
Queue.prototype.getPendingLength = function () {
return this.pendingPromises;
};
/**
* Number of queued promises (which are waiting)
*
* @return {number}
*/
Queue.prototype.getQueueLength = function () {
return this.queue.length;
};
/**
* @returns {boolean} true if first item removed from queue
* @private
*/
Queue.prototype._dequeue = function () {
var self = this;
if (this.pendingPromises >= this.maxPendingPromises) {
return false;
}
_createClass(PromiseQueue, [{
key: 'push',
value: function push(task) {
var _this = this;
// Remove from queue
var item = this.queue.shift();
if (!item) {
return false;
}
var priority = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
try {
this.pendingPromises++;
return new Promise(function (resolve, reject) {
_this._queue.push(function () {
return new Promise(task);
}, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
}, {
key: '_operationWorker',
value: function _operationWorker(task, next) {
task().then(next, next);
}
}]);
resolveWith(item.promiseGenerator())
// Forward all stuff
.then(function (value) {
// It is not pending now
self.pendingPromises--;
// It should pass values
item.resolve(value);
self._dequeue();
}, function (err) {
// It is not pending now
self.pendingPromises--;
// It should not mask errors
item.reject(err);
self._dequeue();
}, function (message) {
// It should pass notifications
item.notify(message);
});
} catch (err) {
self.pendingPromises--;
item.reject(err);
self._dequeue();
}
return PromiseQueue;
})();
exports.PromiseQueue = PromiseQueue;
exports['default'] = PromiseQueue;
return true;
};

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

// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
// for a full discussion and Alea implementation.
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var Alea = function () {
// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
// for a full discussion and Alea implementation.
var Alea = function Alea() {
function Mash() {
var n = 0xefc8249d;
var mash = function (data) {
var mash = function mash(data) {
data = data.toString();

@@ -66,3 +66,3 @@ for (var i = 0; i < data.length; i++) {

var random = function () {
var random = function random() {
var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32

@@ -88,3 +88,3 @@ s0 = s1;

var Random = (function () {
var Random = exports.Random = (function () {
function Random() {

@@ -196,3 +196,2 @@ _classCallCheck(this, Random);

exports.Random = Random;
exports['default'] = Random;
exports.default = Random;
'use strict';
Object.defineProperty(exports, '__esModule', {
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StorageManager = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _keys2 = require('fast.js/object/keys');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _keys3 = _interopRequireDefault(_keys2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _forEach = require('fast.js/forEach');
var _lodashObjectKeys = require('lodash/object/keys');
var _forEach2 = _interopRequireDefault(_forEach);
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _eventemitter = require('eventemitter3');
var _lodashFunctionDefer = require('lodash/function/defer');
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _lodashFunctionDefer2 = _interopRequireDefault(_lodashFunctionDefer);
var _eventemitter3 = require('eventemitter3');
var _eventemitter32 = _interopRequireDefault(_eventemitter3);
var _PromiseQueue = require('./PromiseQueue');

@@ -33,2 +30,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -41,3 +42,3 @@ * Manager for dealing with backend storage

var StorageManager = (function () {
var StorageManager = exports.StorageManager = (function () {
function StorageManager(db, options) {

@@ -47,3 +48,3 @@ _classCallCheck(this, StorageManager);

this.db = db;
this._queue = new _PromiseQueue2['default']();
this._queue = new _PromiseQueue2.default(1);
this._storage = {};

@@ -86,3 +87,3 @@ this.reload();

return this._loadedPromise.then(function () {
_this3._storage[key] = _EJSON2['default'].clone(value);
_this3._storage[key] = _EJSON2.default.clone(value);
});

@@ -105,3 +106,3 @@ }

return this._loadedPromise.then(function () {
return _EJSON2['default'].clone(_this5._storage[key]);
return _EJSON2.default.clone(_this5._storage[key]);
});

@@ -114,11 +115,11 @@ }

var emitter = new _eventemitter32['default']();
(0, _lodashFunctionDefer2['default'])(function () {
var emitter = new _eventemitter2.default();
setTimeout(function () {
_this6._loadedPromise.then(function () {
(0, _lodashObjectKeys2['default'])(_this6._storage).forEach(function (k) {
emitter.emit('data', { value: _EJSON2['default'].clone(_this6._storage[k]) });
(0, _forEach2.default)((0, _keys3.default)(_this6._storage), function (k) {
emitter.emit('data', { value: _EJSON2.default.clone(_this6._storage[k]) });
});
emitter.emit('end');
});
});
}, 1);
return emitter;

@@ -136,3 +137,2 @@ }

exports.StorageManager = StorageManager;
exports['default'] = StorageManager;
exports.default = StorageManager;

@@ -12,12 +12,6 @@ 'use strict';

bundlePolyfillsName: 'marsdb.polyfills.js',
bundleAngularName: 'marsdb.angular.js',
bundleLocalStorageName: 'marsdb.localStorage.js',
bundleLocalForageName: 'marsdb.localForage.js',
entry: 'index.js',
entryTests: 'browser_tests.js',
entryPolyfills: 'polyfills.js',
entryAngular: 'dist/angular/index',
entryLocalStorage: 'dist/storages/LocalStorageManager',
entryLocalForage: 'dist/storages/LocalForageManager',
}
};

@@ -18,5 +18,2 @@ 'use strict';

'build:browser',
'build:browser:angular',
'build:browser:localStorage',
//'build:browser:localForage',
'build:browser:min',

@@ -30,12 +27,3 @@ 'build:browser:tests',

return gulp.src(config.src)
.pipe(babel({
comments: true,
compact: false,
blacklist: [
'spec.functionName',
],
optional: [
'es7.trailingFunctionCommas',
]
}))
.pipe(babel())
.pipe(gulp.dest(config.dist));

@@ -65,56 +53,2 @@ });

gulp.task('build:browser:angular', ['build:node'], function() {
var customOpts = {
entries: config.browser.entryAngular,
debug: false,
fullPaths: false
};
return browserify(customOpts)
.exclude('../Collection')
.exclude('../CursorObservable')
.exclude('angular')
.bundle()
.pipe(source(config.browser.bundleAngularName))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser:localStorage', ['build:node'], function() {
var customOpts = {
entries: config.browser.entryLocalStorage,
debug: false,
fullPaths: false,
standalone: 'Mars.Storages.LocalStorage',
};
return browserify(customOpts)
.exclude('../StorageManager')
.exclude('../EJSON')
.bundle()
.pipe(source(config.browser.bundleLocalStorageName))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser:localForage', ['build:node'], function() {
var customOpts = {
entries: config.browser.entryLocalForage,
debug: false,
fullPaths: false,
standalone: 'Mars.Storages.LocalForage',
};
return browserify(customOpts)
.exclude('../StorageManager')
.exclude('../EJSON')
.bundle()
.pipe(source(config.browser.bundleLocalForageName))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser:tests', ['build:node'], function() {

@@ -132,12 +66,3 @@ // Basic options

var transforms = [
babelify.configure({
comments: true,
compact: false,
blacklist: [
'spec.functionName',
],
optional: [
'es7.trailingFunctionCommas',
]
}),
babelify.configure(),
'brfs',

@@ -144,0 +69,0 @@ 'bulkify',

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

import _each from 'fast.js/forEach';
import _map from 'fast.js/map';
import EventEmitter from 'eventemitter3';

@@ -146,3 +148,3 @@ import invariant from 'invariant';

return Promise.all(
docs.map(d => this.insert(d, options))
_map(docs, d => this.insert(d, options))
);

@@ -172,6 +174,6 @@ }

const removeStorgePromises = docs.map(d => {
const removeStorgePromises = _map(docs, d => {
return this.storageManager.delete(d._id);
});
const removeIndexPromises = docs.map(d => {
const removeIndexPromises = _map(docs, d => {
return this.indexManager.deindexDocument(d);

@@ -182,3 +184,3 @@ });

return Promise.all(allPromises).then(() => {
docs.forEach(d => this.emit('remove', null, d));
_each(docs, d => this.emit('remove', null, d));
return docs;

@@ -211,8 +213,8 @@ });

var {original, updated} = result;
updated = updated.map(x => this.create(x));
updated = _map(updated, x => this.create(x));
const updateStorgePromises = updated.map(d => {
const updateStorgePromises = _map(updated, d => {
return this.storageManager.persist(d._id, d);
});
const updateIndexPromises = updated.map((d, i) => {
const updateIndexPromises = _map(updated, (d, i) => {
return this.indexManager.reindexDocument(original[i], d);

@@ -223,3 +225,3 @@ });

return Promise.all(allPromises).then(() => {
updated.forEach((d, i) => {
_each(updated, (d, i) => {
this.emit('update', d, original[i]);

@@ -226,0 +228,0 @@ });

@@ -1,5 +0,4 @@

import _each from 'lodash/collection/each';
import _isObject from 'lodash/lang/isObject';
import _isArray from 'lodash/lang/isArray';
import _isEmpty from 'lodash/lang/isEmpty';
import _each from 'fast.js/forEach';
import _map from 'fast.js/map';
import _check from 'check-types';
import EventEmitter from 'eventemitter3';

@@ -46,3 +45,3 @@ import invariant from 'invariant';

[PIPELINE_TYPE.Join]: (docs, pipeObj, cursor) => {
if (_isArray(docs)) {
if (_check.array(docs)) {
return PIPELINE_PROCESSORS[PIPELINE_TYPE.JoinEach](docs, pipeObj, cursor);

@@ -54,5 +53,5 @@ } else {

[PIPELINE_TYPE.JoinEach]: (docs, pipeObj, cursor) => {
docs = _isArray(docs) ? docs : [docs];
docs = _check.array(docs) ? docs : [docs];
const docsLength = docs.length;
return Promise.all(docs.map((x, i) => (
return Promise.all(_map(docs, (x, i) => (
PIPELINE_PROCESSORS[PIPELINE_TYPE.JoinAll](x, pipeObj, cursor,

@@ -68,5 +67,6 @@ i, docsLength)

let res = pipeObj.value(docs, updatedFn, i, len);
res = _isArray(res) ? res : [res];
res.forEach(observeStopper => {
if (_isObject(observeStopper) && observeStopper.then) {
res = _check.array(res) ? res : [res];
_each(res, observeStopper => {
if (_check.object(observeStopper) && observeStopper.then) {
if (observeStopper.parent) {

@@ -79,6 +79,12 @@ observeStopper.parent(cursor);

});
return Promise.all(res).then(() => docs);
},
[PIPELINE_TYPE.IfNotEmpty]: (docs) => {
return _isEmpty(docs) ? PIPLEINE_STOP_MARKER : docs;
const isEmptyRes = (
!_check.assigned(docs) ||
(_check.array(docs) && _check.emptyArray(docs)) ||
(_check.object(docs) && _check.emptyObject(docs))
);
return isEmptyRes ? PIPLEINE_STOP_MARKER : docs;
},

@@ -286,3 +292,3 @@ };

this._executing = this._matchObjects().then((docs) => {
return docs.map(x => x._id);
return _map(docs, x => x._id);
}).then((ids) => {

@@ -289,0 +295,0 @@ this._executing = null;

@@ -1,3 +0,4 @@

import _size from 'lodash/collection/size';
import _isArray from 'lodash/lang/isArray';
import _check from 'check-types';
import _map from 'fast.js/map';
import _keys from 'fast.js/object/keys';
import Cursor from './Cursor';

@@ -83,2 +84,9 @@ import EJSON from './EJSON';

const cursorThenGenerator = (currPromise) => {
return (successFn, failFn) => {
successFn = this._prepareListener(successFn);
return createStoppablePromise(currPromise.then(successFn, failFn));
};
};
const createStoppablePromise = (currPromise) => {

@@ -88,6 +96,3 @@ return {

stop: stopper,
then: (successFn, failFn) => {
successFn = this._prepareListener(successFn);
return createStoppablePromise(currPromise.then(successFn, failFn));
},
then: cursorThenGenerator(currPromise),
};

@@ -159,3 +164,3 @@ };

) && (
_size(newDoc) !== _size(oldDoc) || (
_keys(newDoc).length !== _keys(oldDoc).length || (
newDoc.updatedAt && (

@@ -215,4 +220,4 @@ !oldDoc.updatedAt ||

_updateLatestIds() {
if (_isArray(this._latestResult)) {
this._latestIds = new Set(this._latestResult.map(x => x._id));
if (_check.array(this._latestResult)) {
this._latestIds = new Set(_map(this._latestResult, x => x._id));
} else if (this._latestResult && this._latestResult._id) {

@@ -219,0 +224,0 @@ this._latestIds = new Set([this._latestResult._id]);

@@ -1,6 +0,5 @@

import _assign from 'lodash/object/assign';
import _isArray from 'lodash/lang/isArray';
import _isString from 'lodash/lang/isString';
import _each from 'lodash/collection/each';
import _size from 'lodash/collection/size';
import _assign from 'fast.js/object/assign';
import _check from 'check-types';
import _each from 'fast.js/forEach';
import _keys from 'fast.js/object/keys';
import invariant from 'invariant';

@@ -22,3 +21,3 @@ import EJSON from './EJSON';

// Ensure raw object
raw = _isString(raw) ? EJSON.parse(raw) : raw;
raw = _check.string(raw) ? EJSON.parse(raw) : raw;

@@ -90,3 +89,3 @@ // Define internal methods

selector._id && selectorIsId(selector._id) &&
_size(selector) === 1)
_keys(selector).length === 1)
);

@@ -99,3 +98,3 @@ }

export function isArray(x) {
return _isArray(x) && !EJSON.isBinary(x);
return _check.array(x) && !EJSON.isBinary(x);
}

@@ -102,0 +101,0 @@

@@ -1,17 +0,10 @@

import _isEmpty from 'lodash/lang/isEmpty';
import _isEqual from 'lodash/lang/isEqual';
import _isArray from 'lodash/lang/isArray';
import _isNumber from 'lodash/lang/isNumber';
import _isObject from 'lodash/lang/isObject';
import _isNaN from 'lodash/lang/isNaN';
import _has from 'lodash/object/has';
import _keys from 'lodash/object/keys';
import _each from 'lodash/collection/each';
import _contains from 'lodash/collection/contains';
import _all from 'lodash/collection/all';
import _map from 'lodash/collection/map';
import _any from 'lodash/collection/any';
import _identity from 'lodash/utility/identity';
import _check from 'check-types';
import _each from 'fast.js/forEach';
import _keys from 'fast.js/object/keys';
import _map from 'fast.js/map';
import _some from 'fast.js/array/some';
import _every from 'fast.js/array/every';
import _indexOf from 'fast.js/array/indexOf';
import GeoJSON from 'geojson-utils';
import EJSON from './EJSON';
import GeoJSON from 'geojson-utils';
import {selectorIsId, isArray, isPlainObject,

@@ -133,3 +126,4 @@ isIndexable, isOperatorObject, isNumericKey,

_getPaths() {
return _keys(this._paths);
return _check.object(this._paths)
? _keys(this._paths) : null;
}

@@ -153,3 +147,3 @@ }

// this function), or $where.
if (!_has(LOGICAL_OPERATORS, key)) {
if (!LOGICAL_OPERATORS.hasOwnProperty(key)) {
throw new Error('Unrecognized logical operator: ' + key);

@@ -210,3 +204,3 @@ }

var ret = {};
ret.result = _any(expanded, function(element) {
ret.result = _some(expanded, function(element) {
var matched = elementMatcher(element.value);

@@ -244,3 +238,3 @@

// (really!). Underscore knows how.
return _isEqual(value, regexp);
return String(value) === String(regexp);
}

@@ -294,7 +288,7 @@ // Regexps only work against strings.

// XXX we should actually implement $eq, which is new in 2.6
var simpleRange = _contains(['$lt', '$lte', '$gt', '$gte'], operator) &&
_isNumber(operand);
var simpleInequality = operator === '$ne' && !_isObject(operand);
var simpleInclusion = _contains(['$in', '$nin'], operator) &&
_isArray(operand) && !_any(operand, _isObject);
var simpleRange = _indexOf(['$lt', '$lte', '$gt', '$gte'], operator) >= 0 &&
_check.number(operand);
var simpleInequality = operator === '$ne' && !_check.object(operand);
var simpleInclusion = _indexOf(['$in', '$nin'], operator) >= 0 &&
_check.array(operand) && !_some(operand, _check.object);

@@ -306,6 +300,6 @@ if (! (operator === '$eq' || simpleRange ||

if (_has(VALUE_OPERATORS, operator)) {
if (VALUE_OPERATORS.hasOwnProperty(operator)) {
operatorMatchers.push(
VALUE_OPERATORS[operator](operand, valueSelector, matcher, isRoot));
} else if (_has(ELEMENT_OPERATORS, operator)) {
} else if (ELEMENT_OPERATORS.hasOwnProperty(operator)) {
var options = ELEMENT_OPERATORS[operator];

@@ -327,3 +321,3 @@ operatorMatchers.push(

selectors, matcher, inElemMatch) {
if (!isArray(selectors) || _isEmpty(selectors)) {
if (!isArray(selectors) || _check.emptyArray(selectors)) {
throw Error('$and/$or/$nor must be nonempty array');

@@ -359,3 +353,3 @@ }

return function(doc) {
var result = _any(matchers, function(f) {
var result = _some(matchers, function(f) {
return f(doc).result;

@@ -373,3 +367,3 @@ });

return function(doc) {
var result = _all(matchers, function(f) {
var result = _every(matchers, function(f) {
return !f(doc).result;

@@ -445,3 +439,6 @@ });

$options: function(operand, valueSelector) {
if (!_has(valueSelector, '$regex')) {
if (
!_check.object(valueSelector) ||
!valueSelector.hasOwnProperty('$regex')
) {
throw Error('$options needs a $regex');

@@ -463,3 +460,3 @@ }

// Not sure why, but this seems to be what MongoDB does.
if (_isEmpty(operand)) {
if (_check.emptyArray(operand)) {
return nothingMatcher;

@@ -492,3 +489,3 @@ }

var maxDistance, point, distance;
if (isPlainObject(operand) && _has(operand, '$geometry')) {
if (isPlainObject(operand) && operand.hasOwnProperty('$geometry')) {
// GeoJSON '2dsphere' mode.

@@ -565,3 +562,3 @@ maxDistance = operand.$maxDistance;

var y = a[1] - b[1];
if (_isNaN(x) || _isNaN(y)) {
if (!_check.number(x) || !_check.number(y)) {
return null;

@@ -576,3 +573,3 @@ }

var pointToArray = function(point) {
return _map(point, _identity);
return _map(point, x => x);
};

@@ -679,3 +676,3 @@

}
return _any(elementMatchers, function(e) {
return _some(elementMatchers, function(e) {
return e(value);

@@ -1021,3 +1018,3 @@ });

var ret = {};
ret.result = _all(subMatchers, function(f) {
ret.result = _every(subMatchers, function(f) {
var subResult = f(docOrBranches);

@@ -1024,0 +1021,0 @@ // Copy a 'distance' number out of the first sub-matcher that has

@@ -1,6 +0,5 @@

import _isObject from 'lodash/lang/isObject';
import _assign from 'lodash/object/assign';
import _each from 'lodash/collection/each';
import _all from 'lodash/collection/all';
import _identity from 'lodash/utility/identity';
import _check from 'check-types';
import _assign from 'fast.js/object/assign';
import _each from 'fast.js/forEach';
import _every from 'fast.js/array/every';
import EJSON from './EJSON';

@@ -110,3 +109,3 @@ import DocumentRetriver from './DocumentRetriver';

if (! _all(keyparts, _identity)) {
if (! _every(keyparts, x => x)) {
throw new Error(

@@ -255,3 +254,3 @@ 'The update path \'' + keypath +

$set: function(target, field, arg) {
if (!_isObject(target)) { // not an array or an object
if (!_check.object(target) && !_check.array(target)) {
const e = new Error('Cannot set property on non-object field');

@@ -258,0 +257,0 @@ e.setPropertyError = true;

@@ -1,5 +0,4 @@

import _isObject from 'lodash/lang/isObject';
import _isArray from 'lodash/lang/isArray';
import _has from 'lodash/object/has';
import _size from 'lodash/collection/size';
import _check from 'check-types';
import _keys from 'fast.js/object/keys';
import _map from 'fast.js/map';
import {selectorIsId, selectorIsIdPerhapsAsObject} from './Document';

@@ -36,5 +35,5 @@

} else if (
_isObject(query) && _has(query, '_id') &&
_isObject(query._id) && _has(query._id, '$in') &&
_isArray(query._id.$in)
_check.object(query) && query.hasOwnProperty('_id') &&
_check.object(query._id) && query._id.hasOwnProperty('$in') &&
_check.array(query._id.$in)
) {

@@ -47,3 +46,3 @@ // and finally fast path for multiple ids

// Retrive optimally
if (_size(selectorIds) > 0) {
if (_check.object(selectorIds) && _keys(selectorIds).length > 0) {
return this.retriveIds(selectorIds);

@@ -76,3 +75,3 @@ } else {

retriveIds(ids) {
const retrPromises = ids.map(id => this.retriveOne(id));
const retrPromises = _map(ids, id => this.retriveOne(id));
return Promise.all(retrPromises);

@@ -79,0 +78,0 @@ }

@@ -1,9 +0,7 @@

import _isEmpty from 'lodash/lang/isEmpty';
import _has from 'lodash/object/has';
import _each from 'lodash/collection/each';
import _contains from 'lodash/collection/contains';
import _all from 'lodash/collection/all';
import _size from 'lodash/collection/size';
import _map from 'lodash/collection/map';
import _pluck from 'lodash/collection/pluck';
import _check from 'check-types';
import _each from 'fast.js/forEach';
import _every from 'fast.js/array/every';
import _map from 'fast.js/map';
import _indexOf from 'fast.js/array/indexOf';
import _keys from 'fast.js/object/keys';
import DocumentMatcher from './DocumentMatcher';

@@ -111,3 +109,3 @@ import {isOperatorObject, MongoTypeComp} from './Document';

_getPaths() {
return _pluck(this._sortSpecParts, 'path');
return _map(this._sortSpecParts, x => x.path);
}

@@ -197,3 +195,3 @@

var path = pathFromIndices(branch.arrayIndices);
if (_has(valuesByIndexAndPath[whichField], path)) {
if (valuesByIndexAndPath[whichField].hasOwnProperty(path)) {
throw Error('duplicate path: ' + path);

@@ -213,3 +211,3 @@ }

// XXX achieve full compatibility here
if (knownPaths && !_has(knownPaths, path)) {
if (knownPaths && !knownPaths.hasOwnProperty(path)) {
throw Error('cannot index parallel arrays');

@@ -222,4 +220,4 @@ }

// non-array field.
if (!_has(valuesByIndexAndPath[whichField], '') &&
_size(knownPaths) !== _size(valuesByIndexAndPath[whichField])) {
if (!valuesByIndexAndPath[whichField].hasOwnProperty('') &&
_keys(knownPaths).length !== _keys(valuesByIndexAndPath[whichField]).length) {
throw Error('cannot index parallel arrays!');

@@ -238,3 +236,3 @@ }

var soleKey = _map(valuesByIndexAndPath, function(values) {
if (!_has(values, '')) {
if (!values.hasOwnProperty('')) {
throw Error('no value in sole key case?');

@@ -250,6 +248,6 @@ }

var key = _map(valuesByIndexAndPath, function(values) {
if (_has(values, '')) {
if (values.hasOwnProperty('')) {
return values[''];
}
if (!_has(values, path)) {
if (!values.hasOwnProperty(path)) {
throw Error('missing path?');

@@ -333,3 +331,3 @@ }

// XXX figure out how geoqueries interact with this stuff
if (_isEmpty(this._sortSpecParts)) {
if (_check.emptyArray(this._sortSpecParts)) {
return;

@@ -379,3 +377,3 @@ }

_each(subSelector, function(operand, operator) {
if (_contains(['$lt', '$lte', '$gt', '$gte'], operator)) {
if (_indexOf(['$lt', '$lte', '$gt', '$gte'], operator) >= 0) {
// XXX this depends on us knowing that these operators don't use any

@@ -407,3 +405,4 @@ // of the arguments to compileElementSelector other than operand.

// or not as we wish.
if (_isEmpty(constraintsByPath[this._sortSpecParts[0].path])) {
const currConstraint = constraintsByPath[this._sortSpecParts[0].path];
if (!_check.assigned(currConstraint) || _check.emptyArray(currConstraint)) {
return;

@@ -413,4 +412,4 @@ }

this._keyFilter = function(key) {
return _all(this._sortSpecParts, function(specPart, index) {
return _all(constraintsByPath[specPart.path], function(f) {
return _every(this._sortSpecParts, function(specPart, index) {
return _every(constraintsByPath[specPart.path], function(f) {
return f(key[index]);

@@ -417,0 +416,0 @@ });

@@ -7,14 +7,25 @@ /**

import Base64 from './Base64';
import _isEmpty from 'lodash/lang/isEmpty';
import _isNaN from 'lodash/lang/isNaN';
import _isArguments from 'lodash/lang/isArguments';
import _has from 'lodash/object/has';
import _keys from 'lodash/object/keys';
import _each from 'lodash/collection/each';
import _some from 'fast.js/array/some';
import _check from 'check-types';
import _keys from 'fast.js/object/keys';
import _each from 'fast.js/forEach';
// Internal utils
function isInfOrNan(val) {
function _isNaN(val) {
return typeof val === 'number' && val != +val;
}
function _has(obj, key) {
return _check.object(obj) && obj.hasOwnProperty(key);
}
function _isInfOrNan(val) {
return _isNaN(val) || val === Infinity || val === -Infinity;
}
function _isArguments(val) {
return (
!!val && typeof val == 'object' &&
Object.prototype.hasOwnProperty.call(val, 'callee') &&
!Object.prototype.propertyIsEnumerable.call(val, 'callee')
);
}

@@ -245,3 +256,3 @@

if (Array.isArray(v) || _isArguments(v)) {
if (_check.array(v) || _isArguments(v)) {
ret = [];

@@ -296,3 +307,3 @@ for (let i = 0; i < v.length; i++) {

},
matchObject: isInfOrNan,
matchObject: _isInfOrNan,
toJSONValue: (obj) => {

@@ -335,6 +346,9 @@ var sign;

matchObject: (obj) => {
if (_isEmpty(obj) || _keys(obj).length > 2) {
if (
!_check.assigned(obj) || _check.emptyObject(obj) ||
(_check.object(obj) && _keys(obj).length > 2)
) {
return false;
}
return this._builtinConverters.some((converter) => {
return _some(this._builtinConverters, (converter) => {
return converter.matchJSONValue(obj);

@@ -411,3 +425,3 @@ });

if (typeof value !== 'object' && value !== undefined &&
!isInfOrNan(value)) {
!_isInfOrNan(value)) {
return;

@@ -414,0 +428,0 @@ }

@@ -1,6 +0,8 @@

import _keys from 'lodash/object/keys';
import _keys from 'fast.js/object/keys';
import _each from 'fast.js/forEach';
import _map from 'fast.js/map';
import invariant from 'invariant';
import PromiseQueue from './PromiseQueue';
import CollectionIndex from './CollectionIndex';
import DocumentRetriver from './DocumentRetriver';
import PromiseQueue from './PromiseQueue';

@@ -18,5 +20,3 @@

this.indexes = {};
this._queue = new PromiseQueue({
concurrency: options.concurrency || 2,
});
this._queue = new PromiseQueue(options.concurrency || 2);

@@ -77,5 +77,4 @@ // By default ensure index by _id field

const cleanup = () => this.indexes[key].buildPromise = null;
const buildPromise = this._queue.push(
this._doBuildIndex.bind(this, key),
10
const buildPromise = this._queue.add(
this._doBuildIndex.bind(this, key)
).then(cleanup, cleanup);

@@ -95,3 +94,3 @@

return Promise.all(
_keys(this.indexes).map(k => {
_map(_keys(this.indexes), k => {
return this.ensureIndex({

@@ -111,6 +110,5 @@ fieldName: k,

removeIndex(key) {
return this._queue.push((resolve, reject) => {
return this._queue.add(() => {
delete this.indexes[key];
resolve();
}, 10);
});
}

@@ -124,18 +122,17 @@

indexDocument(doc) {
return this._queue.push((resolve, reject) => {
return this._queue.add(() => {
const keys = _keys(this.indexes);
let failingIndex = null;
try {
keys.forEach((k, i) => {
_each(keys, (k, i) => {
failingIndex = i;
this.indexes[k].insert(doc);
});
resolve();
} catch (e) {
keys.slice(0, failingIndex).forEach((k) => {
_each(keys.slice(0, failingIndex), (k) => {
this.indexes[k].remove(doc);
});
reject(e);
throw e;
}
}, 1);
});
}

@@ -151,18 +148,17 @@

reindexDocument(oldDoc, newDoc) {
return this._queue.push((resolve, reject) => {
return this._queue.add(() => {
const keys = _keys(this.indexes);
let failingIndex = null;
try {
keys.forEach((k, i) => {
_each(keys, (k, i) => {
failingIndex = i;
this.indexes[k].update(oldDoc, newDoc);
});
resolve();
} catch (e) {
keys.slice(0, failingIndex).forEach((k) => {
_each(keys.slice(0, failingIndex), (k) => {
this.indexes[k].revertUpdate(oldDoc, newDoc);
});
reject(e);
throw e;
}
}, 1);
});
}

@@ -176,9 +172,8 @@

deindexDocument(doc) {
return this._queue.push((resolve, reject) => {
return this._queue.add(() => {
const keys = _keys(this.indexes);
keys.forEach((k) => {
_each(keys, (k) => {
this.indexes[k].remove(doc);
});
resolve();
}, 1);
});
}

@@ -191,3 +186,3 @@

*/
_doBuildIndex(key, resolve, reject) {
_doBuildIndex(key) {
// Get and reset index

@@ -199,4 +194,4 @@ const index = this.indexes[key];

const errors = [];
new DocumentRetriver(this.db).retriveAll().then((docs) => {
docs.forEach(doc => {
return new DocumentRetriver(this.db).retriveAll().then((docs) => {
_each(docs, doc => {
try {

@@ -209,6 +204,4 @@ index.insert(doc);

if (errors.length) {
resolve();
} else {
reject(errors);
if (errors.length > 0) {
throw new Error('Index build failed with errors: ', errors);
}

@@ -215,0 +208,0 @@ });

@@ -1,36 +0,157 @@

import {queue as PriorityQueue} from 'async';
/**
* @return {Object}
*/
var LocalPromise = typeof Promise !== 'undefined' ? Promise : function() {
return {
then: function() {
throw new Error('Queue.configure() before use Queue');
},
};
};
var noop = function() {};
/**
* Queue that resolves a Promise when task
* is done or rejected if errored.
* @param {*} value
* @returns {LocalPromise}
*/
export class PromiseQueue {
constructor(options = {}) {
this._queue = PriorityQueue(
this._operationWorker.bind(this),
options.concurrency || 1
);
var resolveWith = function(value) {
if (value && typeof value.then === 'function') {
return value;
}
push(task, priority = 1) {
return new Promise((resolve, reject) => {
this._queue.push(
() => new Promise(task),
(err) => {
if (err) {
reject(err);
} else {
resolve();
}
}
);
return new LocalPromise(function(resolve) {
resolve(value);
});
};
/**
* It limits concurrently executed promises
*
* @param {Number} [maxPendingPromises=Infinity] max number of concurrently executed promises
* @param {Number} [maxQueuedPromises=Infinity] max number of queued promises
* @constructor
*
* @example
*
* var queue = new Queue(1);
*
* queue.add(function () {
* // resolve of this promise will resume next request
* return downloadTarballFromGithub(url, file);
* })
* .then(function (file) {
* doStuffWith(file);
* });
*
* queue.add(function () {
* return downloadTarballFromGithub(url, file);
* })
* // This request will be paused
* .then(function (file) {
* doStuffWith(file);
* });
*/
export default function Queue(maxPendingPromises, maxQueuedPromises) {
this.pendingPromises = 0;
this.maxPendingPromises = typeof maxPendingPromises !== 'undefined' ? maxPendingPromises : Infinity;
this.maxQueuedPromises = typeof maxQueuedPromises !== 'undefined' ? maxQueuedPromises : Infinity;
this.queue = [];
}
/**
* Defines promise promiseFactory
* @param {Function} GlobalPromise
*/
Queue.configure = function(GlobalPromise) {
LocalPromise = GlobalPromise;
};
/**
* @param {Function} promiseGenerator
* @return {LocalPromise}
*/
Queue.prototype.add = function(promiseGenerator) {
var self = this;
return new LocalPromise(function(resolve, reject, notify) {
// Do not queue to much promises
if (self.queue.length >= self.maxQueuedPromises) {
reject(new Error('Queue limit reached'));
return;
}
// Add to queue
self.queue.push({
promiseGenerator: promiseGenerator,
resolve: resolve,
reject: reject,
notify: notify || noop,
});
self._dequeue();
});
};
/**
* Number of simultaneously running promises (which are resolving)
*
* @return {number}
*/
Queue.prototype.getPendingLength = function() {
return this.pendingPromises;
};
/**
* Number of queued promises (which are waiting)
*
* @return {number}
*/
Queue.prototype.getQueueLength = function() {
return this.queue.length;
};
/**
* @returns {boolean} true if first item removed from queue
* @private
*/
Queue.prototype._dequeue = function() {
var self = this;
if (this.pendingPromises >= this.maxPendingPromises) {
return false;
}
_operationWorker(task, next) {
task().then(next, next);
// Remove from queue
var item = this.queue.shift();
if (!item) {
return false;
}
}
export default PromiseQueue;
try {
this.pendingPromises++;
resolveWith(item.promiseGenerator())
// Forward all stuff
.then(function(value) {
// It is not pending now
self.pendingPromises--;
// It should pass values
item.resolve(value);
self._dequeue();
}, function(err) {
// It is not pending now
self.pendingPromises--;
// It should not mask errors
item.reject(err);
self._dequeue();
}, function(message) {
// It should pass notifications
item.notify(message);
});
} catch (err) {
self.pendingPromises--;
item.reject(err);
self._dequeue();
}
return true;
};

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

import _keys from 'lodash/object/keys';
import _defer from 'lodash/function/defer';
import _keys from 'fast.js/object/keys';
import _each from 'fast.js/forEach';
import EventEmitter from 'eventemitter3';

@@ -17,3 +17,3 @@ import PromiseQueue from './PromiseQueue';

this.db = db;
this._queue = new PromiseQueue();
this._queue = new PromiseQueue(1);
this._storage = {};

@@ -63,5 +63,5 @@ this.reload();

const emitter = new EventEmitter();
_defer(() => {
setTimeout(() => {
this._loadedPromise.then(() => {
_keys(this._storage).forEach((k) => {
_each(_keys(this._storage), (k) => {
emitter.emit('data', {value: EJSON.clone(this._storage[k])});

@@ -71,3 +71,3 @@ });

});
});
}, 1);
return emitter;

@@ -74,0 +74,0 @@ }

{
"name": "marsdb",
"version": "0.3.14",
"version": "0.4.0",
"author": {

@@ -27,39 +27,39 @@ "name": "Artem Artemev",

"dependencies": {
"async": "1.4.2",
"core-js": "^1.2.2",
"check-types": "^5.1.0",
"core-js": "^2.0.0",
"eventemitter3": "1.1.1",
"fast.js": "^0.1.1",
"geojson-utils": "^1.1.0",
"invariant": "^2.1.1",
"keymirror": "^0.1.1",
"lodash": "3.10.x"
"invariant": "^2.2.0",
"keymirror": "^0.1.1"
},
"devDependencies": {
"angular": "^1.4.7",
"angular-mocks": "^1.4.7",
"babel": "^5.8.23",
"babel-eslint": "^4.1.1",
"babelify": "^6.3.0",
"lodash": "3.10.x",
"babel-cli": "^6.3.17",
"babel-eslint": "^5.0.0-beta6",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.3.13",
"babelify": "^7.2.0",
"brfs": "^1.4.1",
"browserify": "^11.2.0",
"browserify": "^12.0.1",
"bulk-require": "^0.2.1",
"bulkify": "^1.1.1",
"chai": "^3.2.0",
"chai-as-promised": "^5.1.0",
"coveralls": "^2.11.4",
"del": "^2.0.2",
"chai": "^3.4.1",
"chai-as-promised": "^5.2.0",
"coveralls": "^2.11.6",
"del": "^2.2.0",
"envify": "^3.4.0",
"fbjs-scripts": "^0.2.2",
"fbjs-scripts": "^0.5.0",
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-eslint": "^1.0.0",
"gulp-babel": "^6.1.1",
"gulp-eslint": "^1.1.1",
"gulp-if": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.4.2",
"istanbul": "^0.4.0",
"localforage": "^1.3.0",
"mocha": "^2.3.2",
"gulp-uglify": "^1.5.1",
"istanbul": "^1.0.0-alpha.2",
"mocha": "^2.3.4",
"mocha-lcov-reporter": "^1.0.0",
"mocha-phantomjs": "^4.0.1",
"mocha-phantomjs": "^4.0.2",
"require-dir": "^0.3.0",
"run-sequence": "^1.1.2",
"run-sequence": "^1.1.5",
"vinyl-buffer": "^1.0.0",

@@ -72,4 +72,4 @@ "vinyl-source-stream": "^1.1.0"

"test": "mocha --require babelhook --reporter spec --timeout 1000 test/both test/node",
"coverage": "istanbul cover _mocha --require babelhook test/both test/node -- -u exports -R spec && open coverage/lcov-report/index.html",
"coveralls": "istanbul cover _mocha --require babelhook test/both test/node --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"coverage": "./node_modules/.bin/babel-node ./node_modules/istanbul/lib/cli cover _mocha test/both test/node -- -u exports -R spec && open coverage/lcov-report/index.html",
"coveralls": "./node_modules/.bin/babel-node ./node_modules/istanbul/lib/cli cover _mocha test/both test/node --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js ./lib && rm -rf ./coverage"
},

@@ -76,0 +76,0 @@ "main": "index.js",

@@ -12,3 +12,3 @@ <div style="text-align:center"><img src="https://static.studytime.me/marsdb.png" /></div>

MarsDB is a lightweight client-side database.
It's based on a Meteor’s `minimongo` matching/modifying implementation. It's carefully written on `ES6`, usess `modular lodash`, have a `Promise` based interface and may be backed with any storage implementation (LevelUP, LocalStorage, IndexedDB, etc). For now implemented only LocalStorage and [LocalForage](https://github.com/mozilla/localForage) storage managers. It's also supports `observable` cursors.
It's based on a Meteor’s `minimongo` matching/modifying implementation. It's carefully written on `ES6`, have a `Promise` based interface and may be backed with any storage implementation (LevelUP, LocalStorage, IndexedDB, etc). For now implemented only LocalStorage and [LocalForage](https://github.com/mozilla/localForage) storage managers. It's also supports `observable` cursors.

@@ -15,0 +15,0 @@ MarsDB supports any kind of find/update/remove operations that Meteor’s minimongo does. So, go to the Meteor docs for supported query/modifier operations.

import {Document} from '../../lib/Document';
import Collection from '../../lib/Collection';
import async from 'async';
import chai, {expect} from 'chai';

@@ -5,0 +4,0 @@ chai.use(require('chai-as-promised'));

import Collection from '../../lib/Collection';
import Cursor from '../../lib/Cursor';
import async from 'async';
import chai from 'chai';

@@ -5,0 +4,0 @@ chai.use(require('chai-as-promised'));

import Collection from '../../lib/Collection';
import CursorObservable from '../../lib/CursorObservable';
import async from 'async';
import chai, {expect} from 'chai';

@@ -5,0 +4,0 @@ chai.use(require('chai-as-promised'));

@@ -47,3 +47,3 @@ import EJSON from '../../lib/EJSON';

describe('DocumentMatcher', () => {
describe('DocumentSorter', () => {
it('should corerctly sort respect to BSON ordering', function () {

@@ -50,0 +50,0 @@ var shortBinary = EJSON.newBinary(1);

import Collection from '../../lib/Collection';
import DocumentRetriver from '../../lib/DocumentRetriver';
import async from 'async';
import chai from 'chai';

@@ -5,0 +4,0 @@ chai.use(require('chai-as-promised'));

import StorageManager from '../../lib/StorageManager';
import async from 'async';
import chai from 'chai';

@@ -4,0 +3,0 @@ chai.use(require('chai-as-promised'));

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 too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc