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

@nozbe/lokijs

Package Overview
Dependencies
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nozbe/lokijs - npm Package Compare versions

Comparing version 1.5.12-wmelon4 to 1.5.12-wmelon5

4

build/lokijs.wmelon.min.js

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

!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.loki=e()}(this,function(){return function(){"use strict";function t(i){var n,r;if(Array.isArray(i)){for(r=0;r<i.length;r++)t(i[r]);e(i)}else if(null!==i&&"object"==typeof i){for(n in i)i.hasOwnProperty(n)&&t(i[n]);e(i)}}function e(t){Object.isFrozen(t)||Object.freeze(t)}function i(t){return Object.isFrozen(t)?d(t,"shallow"):t}function n(t,e){var i,n,r,s;if(t===e)return!0;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:r=1;break;case!1:r=3;break;case!0:r=4;break;case"":r=5;break;default:r=t===t?9:0}switch(e){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=e===e?9:0}if(9!==r||9!==s)return r===s}return i=Number(t),n=Number(e),i===i||n===n?i===n:(i=t.toString(),n=e.toString(),i==n)}function r(t,e,i){var n,r,s,a;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=t===t?9:0}switch(e){case void 0:case null:a=1;break;case!1:a=3;break;case!0:a=4;break;case"":a=5;break;default:a=e===e?9:0}if(9!==s||9!==a)return s===a?i:s<a}return n=Number(t),r=Number(e),n===n&&r===r?n<r||!(n>r)&&i:n===n&&r!==r||(r!==r||n===n)&&(t<e||!(t>e)&&(t==e?i:(n=t.toString(),r=e.toString(),n<r||n==r&&i)))}function s(t,e,i){var n,r,s,a;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=t===t?9:0}switch(e){case void 0:case null:a=1;break;case!1:a=3;break;case!0:a=4;break;case"":a=5;break;default:a=e===e?9:0}if(9!==s||9!==a)return s===a?i:s>a}return n=Number(t),r=Number(e),n===n&&r===r?n>r||!(n<r)&&i:(n!==n||r===r)&&(r===r&&n!==n||(t>e||!(t<e)&&(t==e?i:(n=t.toString(),r=e.toString(),n>r||n==r&&i))))}function a(t,e,i){return w.aeq(t,e)?0:w.lt(t,e,!1)?i?1:-1:w.gt(t,e,!1)?i?-1:1:0}function o(t,e,i){for(var n,r,s,o,l,h=0,c=0,d=t.length;c<d;c++)if(n=t[c],r=n[0],~r.indexOf(".")?(l=r.split("."),s=m.getIn(e,l,!0),o=m.getIn(i,l,!0)):(s=e[r],o=i[r]),0!==(h=a(s,o,n[1])))return h;return 0}function l(t,e,i,n,r,s){var a,o=s||0,h=e[o],c=!1;if("object"==typeof t&&h in t&&(a=t[h]),o+1>=e.length)c=i(a,n,r);else if(Array.isArray(a))for(var d=0,u=a.length;d<u&&!0!==(c=l(a[d],e,i,n,r,o+1));d+=1);else c=l(a,e,i,n,r,o+1);return c}function h(t){return"string"==typeof t||Array.isArray(t)?function(e){return-1!==t.indexOf(e)}:"object"==typeof t&&null!==t?function(e){return I.call(t,e)}:null}function c(t,e,i){for(var n in e)if(I.call(e,n))return O[n](t,e[n],i);return!1}function d(t,e){if(null===t||void 0===t)return null;var i,n=e||"parse-stringify";switch(n){case"parse-stringify":i=JSON.parse(JSON.stringify(t))}return i}function u(){}function f(t,e){this.filename=t||"loki.db",this.collections=[],this.databaseVersion=1.5,this.engineVersion=1.5,this.autosave=!1,this.autosaveInterval=5e3,this.autosaveHandle=null,this.throttledSaves=!0,this.options={},this.persistenceMethod=null,this.persistenceAdapter=null,this.throttledSavePending=!1,this.throttledCallbacks=[],this.verbose=!(!e||!e.hasOwnProperty("verbose"))&&e.verbose,this.events={init:[],loaded:[],flushChanges:[],close:[],changes:[],warning:[]},this.configureOptions(e,!0)}function p(t){this.hashStore={},this.options=t||{},this.options.hasOwnProperty("asyncResponses")||(this.options.asyncResponses=!1),this.options.hasOwnProperty("asyncTimeout")||(this.options.asyncTimeout=50)}function y(t,e){return e=e||{},this.collection=t,this.filteredrows=[],this.filterInitialized=!1,this}function v(t,e){if("$regex"===t)Array.isArray(e)?e=new RegExp(e[0],e[1]):e instanceof RegExp||(e=new RegExp(e));else if("object"==typeof e)for(var i in e)"$regex"!==i&&"object"!=typeof e[i]||(e[i]=v(i,e[i]));return e}function g(t,e){this.name=t,this.data=[],this.idIndex=null,this.binaryIndices={},this.constraints={unique:{},exact:{}},this.uniqueNames=[],this.transforms={},this.objType=t,this.dirty=!0,this.cachedIndex=null,this.cachedBinaryIndex=null,this.cachedData=null;var i=this;e=e||{},e.hasOwnProperty("unique")&&(Array.isArray(e.unique)||(e.unique=[e.unique]),e.unique.forEach(function(t){i.uniqueNames.push(t)})),this.adaptiveBinaryIndices=!e.hasOwnProperty("adaptiveBinaryIndices")||e.adaptiveBinaryIndices,this.transactional=!!e.hasOwnProperty("transactional")&&e.transactional,this.cloneObjects=!!e.hasOwnProperty("clone")&&e.clone,this.cloneMethod=e.hasOwnProperty("cloneMethod")?e.cloneMethod:"parse-stringify",this.asyncListeners=!!e.hasOwnProperty("asyncListeners")&&e.asyncListeners,this.disableMeta=!!e.hasOwnProperty("disableMeta")&&e.disableMeta,this.disableChangesApi=!e.hasOwnProperty("disableChangesApi")||e.disableChangesApi,this.disableDeltaChangesApi=!e.hasOwnProperty("disableDeltaChangesApi")||e.disableDeltaChangesApi,this.disableChangesApi&&(this.disableDeltaChangesApi=!0),this.autoupdate=!!e.hasOwnProperty("autoupdate")&&e.autoupdate,this.serializableIndices=!e.hasOwnProperty("serializableIndices")||e.serializableIndices,this.disableFreeze=!e.hasOwnProperty("disableFreeze")||e.disableFreeze,this.maxId=0,this.DynamicViews=[],this.events={insert:[],update:[],"pre-insert":[],"pre-update":[],close:[],flushbuffer:[],error:[],delete:[],warning:[]},this.changes=[],this.dirtyIds=[];var n=[];if(e&&e.indices)if("[object Array]"===Object.prototype.toString.call(e.indices))n=e.indices;else{if("string"!=typeof e.indices)throw new TypeError("Indices needs to be a string or an array of strings");n=[e.indices]}for(var r=0;r<n.length;r++)this.ensureIndex(n[r]);this.on("warning",function(t){i.lokiConsoleWrapper.warn(t)})}function b(t){this.field=t,this.keyMap=Object.create(null),this.lokiMap=Object.create(null)}var I=Object.prototype.hasOwnProperty,m={copyProperties:function(t,e){var i;for(i in t)e[i]=t[i]},getIn:function(t,e,i){if(null!=t){if(!i)return t[e];if("string"==typeof e&&(e=e.split(".")),!Array.isArray(e))throw new Error("path must be a string or array. Found "+typeof e);for(var n=0,r=e.length;null!=t&&n<r;)t=t[e[n++]];return n&&n==r?t:void 0}}},w={aeq:n,lt:r,gt:s},O={$eq:function(t,e){return t===e},$aeq:function(t,e){return t==e},$ne:function(t,e){return e!==e?t===t:t!==e},$dteq:function(t,e){return w.aeq(t,e)},$gt:function(t,e){return w.gt(t,e,!1)},$gte:function(t,e){return w.gt(t,e,!0)},$lt:function(t,e){return w.lt(t,e,!1)},$lte:function(t,e){return w.lt(t,e,!0)},$jgt:function(t,e){return t>e},$jgte:function(t,e){return t>=e},$jlt:function(t,e){return t<e},$jlte:function(t,e){return t<=e},$between:function(t,e){return void 0!==t&&null!==t&&(w.gt(t,e[0],!0)&&w.lt(t,e[1],!0))},$jbetween:function(t,e){return void 0!==t&&null!==t&&(t>=e[0]&&t<=e[1])},$in:function(t,e){return-1!==e.indexOf(t)},$inSet:function(t,e){return e.has(t)},$nin:function(t,e){return-1===e.indexOf(t)},$keyin:function(t,e){return t in e},$nkeyin:function(t,e){return!(t in e)},$definedin:function(t,e){return void 0!==e[t]},$undefinedin:function(t,e){return void 0===e[t]},$regex:function(t,e){return e.test(t)},$containsString:function(t,e){return"string"==typeof t&&-1!==t.indexOf(e)},$containsNone:function(t,e){return!O.$containsAny(t,e)},$containsAny:function(t,e){var i=h(t);return null!==i&&(Array.isArray(e)?e.some(i):i(e))},$contains:function(t,e){var i=h(t);return null!==i&&(Array.isArray(e)?e.every(i):i(e))},$elemMatch:function(t,e){return!!Array.isArray(t)&&t.some(function(t){return Object.keys(e).every(function(i){var n=e[i];return"object"==typeof n&&n||(n={$eq:n}),-1!==i.indexOf(".")?l(t,i.split("."),c,e[i],t):c(t[i],n,t)})})},$type:function(t,e,i){var n=typeof t;return"object"===n&&(Array.isArray(t)?n="array":t instanceof Date&&(n="date")),"object"!=typeof e?n===e:c(n,e,i)},$finite:function(t,e){return e===isFinite(t)},$size:function(t,e,i){return!!Array.isArray(t)&&("object"!=typeof e?t.length===e:c(t.length,e,i))},$len:function(t,e,i){return"string"==typeof t&&("object"!=typeof e?t.length===e:c(t.length,e,i))},$where:function(t,e){return!0===e(t)},$not:function(t,e,i){return!c(t,e,i)},$and:function(t,e,i){for(var n=0,r=e.length;n<r;n+=1)if(!c(t,e[n],i))return!1;return!0},$or:function(t,e,i){for(var n=0,r=e.length;n<r;n+=1)if(c(t,e[n],i))return!0;return!1},$exists:function(t,e){return e?void 0!==t:void 0===t}};["$eq","$aeq","$ne","$dteq","$gt","$gte","$lt","$lte","$jgt","$jgte","$jlt","$jlte","$type"].forEach(function(t){var e=O[t];O["$"+t]=function(t,i,n){if("string"==typeof i)return e(t,n[i]);if("function"==typeof i)return e(t,i(n));throw new Error("Invalid argument to $$ matcher")}});var $={$eq:O.$eq,$aeq:!0,$dteq:!0,$gt:!0,$gte:!0,$lt:!0,$lte:!0,$in:!0,$between:!0};return u.prototype.events={},u.prototype.asyncListeners=!1,u.prototype.on=function(t,e){var i,n=this;return Array.isArray(t)?(t.forEach(function(t){n.on(t,e)}),e):(i=this.events[t],i||(i=this.events[t]=[]),i.push(e),e)},u.prototype.emit=function(t){var e,i=this;if(!t||!this.events[t])throw new Error("No event "+t+" defined");this.events[t].length&&(e=Array.prototype.slice.call(arguments,1),this.events[t].forEach(function(t){i.asyncListeners?setTimeout(function(){t.apply(i,e)},1):t.apply(i,e)}))},u.prototype.addListener=u.prototype.on,u.prototype.removeListener=function(t,e){var i=this;if(Array.isArray(t))return void t.forEach(function(t){i.removeListener(t,e)});if(this.events[t]){var n=this.events[t];n.splice(n.indexOf(e),1)}},f.prototype=new u,f.prototype.constructor=f,f.prototype.configureOptions=function(t,e){var i={NODEJS:"fs",BROWSER:"localStorage",CORDOVA:"localStorage",MEMORY:"memory"},n={memory:p};if(this.options={},this.persistenceMethod=null,this.persistenceAdapter=null,void 0!==t){if(this.options=t,this.options.hasOwnProperty("persistenceMethod")&&"function"==typeof n[t.persistenceMethod]&&(this.persistenceMethod=t.persistenceMethod,this.persistenceAdapter=new n[t.persistenceMethod]),this.options.hasOwnProperty("adapter")&&(this.persistenceMethod="adapter",this.persistenceAdapter=t.adapter,this.options.adapter=null,this.isIncremental="incremental"===this.persistenceAdapter.mode),t.autoload&&e){var r=this;setTimeout(function(){r.loadDatabase(t,t.autoloadCallback)},1)}this.options.hasOwnProperty("autosaveInterval")&&(this.autosaveDisable(),this.autosaveInterval=parseInt(this.options.autosaveInterval,10)),this.options.hasOwnProperty("autosave")&&this.options.autosave&&(this.autosaveDisable(),this.autosave=!0,this.options.hasOwnProperty("autosaveCallback")?this.autosaveEnable(t,t.autosaveCallback):this.autosaveEnable()),this.options.hasOwnProperty("throttledSaves")&&(this.throttledSaves=this.options.throttledSaves)}this.options.hasOwnProperty("serializationMethod")||(this.options.serializationMethod="normal"),this.options.hasOwnProperty("destructureDelimiter")||(this.options.destructureDelimiter="$<\n"),null===this.persistenceAdapter&&(this.persistenceMethod=i[this.ENV],this.persistenceMethod&&(this.persistenceAdapter=new n[this.persistenceMethod]))},f.prototype.copy=function(t){var e,i,n=new f(this.filename,{env:"NA"});if(t=t||{},n.loadJSONObject(this,{retainDirtyFlags:!0}),t.hasOwnProperty("removeNonSerializable")&&!0===t.removeNonSerializable)for(n.autosaveHandle=null,n.persistenceAdapter=null,e=n.collections.length,i=0;i<e;i++)n.collections[i].constraints=null,n.collections[i].ttl=null;return n},f.prototype.addCollection=function(t,e){var i,n=this.collections.length;for(i=0;i<n;i+=1)if(this.collections[i].name===t)return this.collections[i];var r=new g(t,e);return r.isIncremental=this.isIncremental,this.collections.push(r),this.verbose&&(r.lokiConsoleWrapper=console),r},f.prototype.loadCollection=function(t){if(!t.name)throw new Error("Collection must have a name property to be loaded");this.collections.push(t)},f.prototype.getCollection=function(t){var e,i=this.collections.length;for(e=0;e<i;e+=1)if(this.collections[e].name===t)return this.collections[e];return this.emit("warning","collection "+t+" not found"),null},f.prototype.renameCollection=function(t,e){var i=this.getCollection(t);return i&&(i.name=e),i},f.prototype.removeCollection=function(t){var e,i=this.collections.length;for(e=0;e<i;e+=1)if(this.collections[e].name===t){var n=new g(t,{}),r=this.collections[e];for(var s in r)r.hasOwnProperty(s)&&n.hasOwnProperty(s)&&(r[s]=n[s]);return void this.collections.splice(e,1)}},f.prototype.getName=function(){return this.name},f.prototype.serializeReplacer=function(t,e){switch(t){case"autosaveHandle":case"persistenceAdapter":case"constraints":case"ttl":return null;case"throttledSavePending":case"throttledCallbacks":return;case"lokiConsoleWrapper":return null;default:return e}},f.prototype.serialize=function(t){switch(t=t||{},t.hasOwnProperty("serializationMethod")||(t.serializationMethod=this.options.serializationMethod),t.serializationMethod){case"normal":return JSON.stringify(this,this.serializeReplacer);case"pretty":return JSON.stringify(this,this.serializeReplacer,2);case"destructured":return this.serializeDestructured();default:return JSON.stringify(this,this.serializeReplacer)}},f.prototype.toJson=f.prototype.serialize,f.prototype.loadJSON=function(t,e){var i;if(0===t.length)i={};else switch(this.options.serializationMethod){case"normal":case"pretty":i=JSON.parse(t);break;case"destructured":i=this.deserializeDestructured(t);break;default:i=JSON.parse(t)}this.loadJSONObject(i,e)},f.prototype.loadJSONObject=function(e,i){var n,r,s,a,o,l,h=0,c=e.collections?e.collections.length:0;for(this.name=e.name,e.hasOwnProperty("throttledSaves")&&i&&!i.hasOwnProperty("throttledSaves")&&(this.throttledSaves=e.throttledSaves),this.collections=[],h;h<c;h+=1){if(n=e.collections[h],r=this.addCollection(n.name,{disableChangesApi:n.disableChangesApi,disableDeltaChangesApi:n.disableDeltaChangesApi,disableMeta:n.disableMeta,disableFreeze:!n.hasOwnProperty("disableFreeze")||n.disableFreeze}),r.adaptiveBinaryIndices=!!n.hasOwnProperty("adaptiveBinaryIndices")&&!0===n.adaptiveBinaryIndices,r.transactional=n.transactional,r.asyncListeners=n.asyncListeners,r.cloneObjects=n.cloneObjects,r.cloneMethod=n.cloneMethod||"parse-stringify",r.autoupdate=n.autoupdate,r.changes=n.changes,r.dirtyIds=n.dirtyIds||[],i&&!0===i.retainDirtyFlags?r.dirty=n.dirty:r.dirty=!1,s=n.data.length,a=0,i&&i.hasOwnProperty(n.name))for(o=function(t){var e,n=i[t.name];return n.proto?(e=n.inflate||m.copyProperties,function(t){var i=new n.proto;return e(t,i),i}):n.inflate}(n),a;a<s;a++)l=o(n.data[a]),r.data[a]=l,r.addAutoUpdateObserver(l),r.disableFreeze||t(r.data[a]);else for(a;a<s;a++)r.data[a]=n.data[a],r.addAutoUpdateObserver(r.data[a]),r.disableFreeze||t(r.data[a]);r.maxId=void 0===n.maxId?0:n.maxId,void 0!==n.binaryIndices&&(r.binaryIndices=n.binaryIndices),void 0!==n.transforms&&(r.transforms=n.transforms),r.uniqueNames=[],n.hasOwnProperty("uniqueNames")&&(r.uniqueNames=n.uniqueNames),e.databaseVersion<1.5&&(r.ensureAllIndexes(!0),r.dirty=!0)}},f.prototype.close=function(t){this.autosave&&(this.autosaveDisable(),this.autosaveDirty()&&(this.saveDatabase(t),t=void 0)),t&&this.on("close",t),this.emit("close")},p.prototype.loadDatabase=function(t,e){var i=this;this.options.asyncResponses?setTimeout(function(){e(i.hashStore.hasOwnProperty(t)?i.hashStore[t].value:null)},this.options.asyncTimeout):e(this.hashStore.hasOwnProperty(t)?this.hashStore[t].value:null)},p.prototype.saveDatabase=function(t,e,i){var n,r=this;this.options.asyncResponses?setTimeout(function(){n=r.hashStore.hasOwnProperty(t)?r.hashStore[t].savecount:0,r.hashStore[t]={savecount:n+1,lastsave:new Date,value:e},i()},this.options.asyncTimeout):(n=this.hashStore.hasOwnProperty(t)?this.hashStore[t].savecount:0,this.hashStore[t]={savecount:n+1,lastsave:new Date,value:e},i())},p.prototype.deleteDatabase=function(t,e){this.hashStore.hasOwnProperty(t)&&delete this.hashStore[t],"function"==typeof e&&e()},f.prototype.throttledSaveDrain=function(t,e){var i=this,n=(new Date).getTime();if(this.throttledSaves||t(!0),e=e||{},e.hasOwnProperty("recursiveWait")||(e.recursiveWait=!0),e.hasOwnProperty("recursiveWaitLimit")||(e.recursiveWaitLimit=!1),e.hasOwnProperty("recursiveWaitLimitDuration")||(e.recursiveWaitLimitDuration=2e3),e.hasOwnProperty("started")||(e.started=(new Date).getTime()),this.throttledSaves&&this.throttledSavePending){if(!e.recursiveWait)return void this.throttledCallbacks.push(t);this.throttledCallbacks.push(function(){return i.throttledSavePending?e.recursiveWaitLimit&&n-e.started>e.recursiveWaitLimitDuration?void t(!1):void i.throttledSaveDrain(t,e):void t(!0)})}else t(!0)},f.prototype.loadDatabaseInternal=function(t,e){var i=e||function(t,e){if(t)throw t},n=this;null!==this.persistenceAdapter?this.persistenceAdapter.loadDatabase(this.filename,function(e){if("string"==typeof e){var r=!1;try{n.loadJSON(e,t||{}),r=!0}catch(t){i(t)}r&&(i(null),n.emit("loaded","database "+n.filename+" loaded"))}else{if(!e)return i(null),void n.emit("loaded","empty database "+n.filename+" loaded");if(e instanceof Error)return void i(e);if("object"==typeof e)return n.loadJSONObject(e,t||{}),i(null),void n.emit("loaded","database "+n.filename+" loaded");i("unexpected adapter response : "+e)}}):i(new Error("persistenceAdapter not configured"))},f.prototype.loadDatabase=function(t,e){var i=this;if(!this.throttledSaves)return void this.loadDatabaseInternal(t,e);this.throttledSaveDrain(function(n){if(n)return i.throttledSavePending=!0,void i.loadDatabaseInternal(t,function(t){0===i.throttledCallbacks.length?i.throttledSavePending=!1:i.saveDatabase(),"function"==typeof e&&e(t)});"function"==typeof e&&e(new Error("Unable to pause save throttling long enough to read database"))},t)},f.prototype.saveDatabaseInternal=function(t){var e=t||function(t){if(t)throw t},i=this;if(!this.persistenceAdapter)return void e(new Error("persistenceAdapter not configured"));if("incremental"===this.persistenceAdapter.mode){var n;this.ignoreAutosave=!0,this.persistenceAdapter.saveDatabase(this.filename,function(){if(i.ignoreAutosave=!1,n)return void e(new Error("adapter error - getLokiCopy called more than once"));var t=i.copy({removeNonSerializable:!0});return n=i.collections.map(function(t){return[t.dirty,t.dirtyIds]}),i.collections.forEach(function(t){t.dirty=!1,t.dirtyIds=[]}),t},function(t){i.ignoreAutosave=!1,t&&n&&i.collections.forEach(function(t,e){var i=n[e];t.dirty=t.dirty||i[0],t.dirtyIds=t.dirtyIds.concat(i[1])}),e(t)})}else"reference"===this.persistenceAdapter.mode&&"function"==typeof this.persistenceAdapter.exportDatabase?this.persistenceAdapter.exportDatabase(this.filename,this.copy({removeNonSerializable:!0}),function(t){i.autosaveClearFlags(),e(t)}):(this.autosaveClearFlags(),this.persistenceAdapter.saveDatabase(this.filename,this.serialize(),function(t){e(t)}))},f.prototype.saveDatabase=function(t){if(!this.throttledSaves)return void this.saveDatabaseInternal(t);if(this.throttledSavePending)return void this.throttledCallbacks.push(t);var e=this.throttledCallbacks;this.throttledCallbacks=[],e.unshift(t),this.throttledSavePending=!0;var i=this;this.saveDatabaseInternal(function(t){i.throttledSavePending=!1,e.forEach(function(e){"function"==typeof e&&setTimeout(function(){e(t)},1)}),i.throttledCallbacks.length>0&&i.saveDatabase()})},f.prototype.save=f.prototype.saveDatabase,f.prototype.deleteDatabase=function(t,e){var i=e||function(t,e){if(t)throw t};"function"!=typeof t||e||(i=t),null!==this.persistenceAdapter?this.persistenceAdapter.deleteDatabase(this.filename,function(t){i(t)}):i(new Error("persistenceAdapter not configured"))},f.prototype.autosaveDirty=function(){for(var t=0;t<this.collections.length;t++)if(this.collections[t].dirty)return!0;return!1},f.prototype.autosaveClearFlags=function(){for(var t=0;t<this.collections.length;t++)this.collections[t].dirty=!1},f.prototype.autosaveEnable=function(t,e){this.autosave=!0;var i=5e3,n=this;void 0!==this.autosaveInterval&&null!==this.autosaveInterval&&(i=this.autosaveInterval),this.autosaveHandle=setInterval(function(){n.autosaveDirty()&&!n.ignoreAutosave&&n.saveDatabase(e)},i)},f.prototype.autosaveDisable=function(){void 0!==this.autosaveHandle&&null!==this.autosaveHandle&&(clearInterval(this.autosaveHandle),this.autosaveHandle=null)},y.prototype.reset=function(){return this.filteredrows.length>0&&(this.filteredrows=[]),this.filterInitialized=!1,this},y.prototype.toJSON=function(){var t=this.copy();return t.collection=null,t},y.prototype.limit=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=new y(this.collection);return e.filteredrows=this.filteredrows.slice(0,t),e.filterInitialized=!0,e},y.prototype.offset=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=new y(this.collection);return e.filteredrows=this.filteredrows.slice(t),e.filterInitialized=!0,e},y.prototype.copy=function(){var t=new y(this.collection);return this.filteredrows.length>0&&(t.filteredrows=this.filteredrows.slice()),t.filterInitialized=this.filterInitialized,t},y.prototype.branch=y.prototype.copy,y.prototype.sort=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=function(t,e){return function(i,n){return t(e[i],e[n])}}(t,this.collection.data);return this.filteredrows.sort(e),this},y.prototype.simplesort=function(t,e){var i,n=10,r=this.collection.data.length,s=this.filteredrows.length,o=this.collection.binaryIndices.hasOwnProperty(t);if(void 0!==e&&!1!==e||(e={desc:!1}),!0===e&&(e={desc:!0}),0===s){if(this.filterInitialized)return this;if(this.collection.binaryIndices.hasOwnProperty(t))return this.collection.ensureIndex(t),this.filteredrows=this.collection.binaryIndices[t].values.slice(0),e.desc&&this.filteredrows.reverse(),this;this.filteredrows=this.collection.prepareFullDocIndex()}else if(!e.disableIndexIntersect&&o&&(i=r/s,e.useJavascriptSorting&&(n=6),i<=n||e.forceIndexIntersect)){var l,h=this.filteredrows,c={};for(l=0;l<s;l++)c[h[l]]=!0;var d=this.collection.binaryIndices[t].values;return this.filteredrows=d.filter(function(t){return c[t]}),e.desc&&this.filteredrows.reverse(),this}if(e.useJavascriptSorting)return this.sort(function(e,i){return e[t]===i[t]?0:e[t]>i[t]?1:e[t]<i[t]?-1:void 0});var u=function(t,e,i){var n,r,s;return function(o,l){return~t.indexOf(".")?(s=t.split("."),n=m.getIn(i[o],s,!0),r=m.getIn(i[l],s,!0)):(n=i[o][t],r=i[l][t]),a(n,r,e)}}(t,e.desc,this.collection.data);return this.filteredrows.sort(u),this},y.prototype.compoundsort=function(t){if(0===t.length)throw new Error("Invalid call to compoundsort, need at least one property");var e;if(1===t.length)return e=t[0],Array.isArray(e)?this.simplesort(e[0],e[1]):this.simplesort(e,!1);for(var i=0,n=t.length;i<n;i+=1)e=t[i],Array.isArray(e)||(t[i]=[e,!1]);this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var r=function(t,e){return function(i,n){return o(t,e[i],e[n])}}(t,this.collection.data);return this.filteredrows.sort(r),this},y.prototype.findOr=function(t){for(var e=null,i=0,n=0,r=[],s=[],a=0,o=(this.count(),0),l=t.length;o<l;o++)for(e=this.branch().find(t[o]).filteredrows,n=e.length,i=0;i<n;i++)a=e[i],void 0===s[a]&&(s[a]=!0,r.push(a));return this.filteredrows=r,this.filterInitialized=!0,this},y.prototype.$or=y.prototype.findOr,y.prototype.findAnd=function(t){for(var e=0,i=t.length;e<i;e++){if(0===this.count())return this;this.find(t[e])}return this},y.prototype.$and=y.prototype.findAnd,y.prototype.find=function(t,e){if(0===this.collection.data.length)return this.filteredrows=[],this.filterInitialized=!0,this;var i,n,r,s,a,o,h,c=t||"getAll",d=!1,u=[],f=[],p=null;if(e=e||!1,"object"==typeof c){for(i in c)s={},s[i]=c[i],f.push(s),I.call(c,i)&&(n=i,r=c[i]);if(f.length>1)return this.find({$and:f},e)}if(!n||"getAll"===c)return e&&(this.filterInitialized?this.filteredrows=this.filteredrows.slice(0,1):(this.filteredrows=this.collection.data.length>0?[0]:[],this.filterInitialized=!0)),this;if("$and"===n||"$or"===n)return this[n](r),e&&this.filteredrows.length>1&&(this.filteredrows=this.filteredrows.slice(0,1)),this;if(null===r||"object"!=typeof r||r instanceof Date)a="$eq",o=r;else{if("object"!=typeof r)throw new Error("Do not know what you want to do.");for(h in r)if(I.call(r,h)){a=h,o=r[h];break}}"$regex"!==a&&"object"!=typeof o||(o=v(a,o));var y=-1!==n.indexOf(".");!this.filterInitialized&&this.collection.binaryIndices[n]&&$[a]&&(!0!==this.collection.adaptiveBinaryIndices&&this.collection.ensureIndex(n),d=!0,p=this.collection.binaryIndices[n]),!d&&"$in"===a&&Array.isArray(o)&&"undefined"!=typeof Set&&(o=new Set(o),a="$inSet");var g,b,w=O[a],k=this.collection.data,A=0,x=0,D=0;if(this.filterInitialized){if(g=this.filteredrows,x=g.length,y){for(n=n.split("."),A=0;A<x;A++)if(D=g[A],b=k[D],l(b,n,w,o,b)&&(u.push(D),e))return this.filteredrows=u,this}else for(A=0;A<x;A++)if(D=g[A],b=k[D],w(b[n],o,b)&&(u.push(D),e))return this.filteredrows=u,this}else if(d){var S=this.collection.calculateRange(a,n,o);if("$in"!==a){for(A=S[0];A<=S[1];A++)if(!0!==$[a]){if($[a](m.getIn(k[p.values[A]],n,y),o)&&(u.push(p.values[A]),e))return this.filteredrows=u,this.filterInitialized=!0,this}else if(u.push(p.values[A]),e)return this.filteredrows=u,this.filterInitialized=!0,this}else for(A=0,x=S.length;A<x;A++)if(u.push(p.values[S[A]]),e)return this.filteredrows=u,this.filterInitialized=!0,this}else if(x=k.length,y){for(n=n.split("."),A=0;A<x;A++)if(b=k[A],l(b,n,w,o,b)&&(u.push(A),e))return this.filteredrows=u,this.filterInitialized=!0,this}else for(A=0;A<x;A++)if(b=k[A],w(b[n],o,b)&&(u.push(A),e))return this.filteredrows=u,this.filterInitialized=!0,this;return this.filteredrows=u,this.filterInitialized=!0,this},y.prototype.where=function(t){var e,i=[];if("function"!=typeof t)throw new TypeError("Argument is not a stored view or a function");e=t;try{if(this.filterInitialized){for(var n=this.filteredrows.length;n--;)!0===e(this.collection.data[this.filteredrows[n]])&&i.push(this.filteredrows[n]);return this.filteredrows=i,this}for(var r=this.collection.data.length;r--;)!0===e(this.collection.data[r])&&i.push(r);return this.filteredrows=i,this.filterInitialized=!0,this}catch(t){throw t}},y.prototype.count=function(){return this.filterInitialized?this.filteredrows.length:this.collection.count()},y.prototype.data=function(t){var e,i,n,r,s=[],a=this.collection.data;if(t=t||{},t.removeMeta&&!t.forceClones&&(t.forceClones=!0,t.forceCloneMethod=t.forceCloneMethod||"shallow"),!this.collection.disableDeltaChangesApi&&this.collection.disableFreeze&&(t.forceClones=!0,t.forceCloneMethod="parse-stringify"),!this.filterInitialized){if(0===this.filteredrows.length){if(this.collection.cloneObjects||t.forceClones){for(i=a.length,r=t.forceCloneMethod||this.collection.cloneMethod,n=0;n<i;n++)e=d(a[n],r),t.removeMeta&&(delete e.$loki,delete e.meta),s.push(e);return s}return a.slice()}this.filterInitialized=!0}var o=this.filteredrows;if(i=o.length,this.collection.cloneObjects||t.forceClones)for(r=t.forceCloneMethod||this.collection.cloneMethod,n=0;n<i;n++)e=d(a[o[n]],r),t.removeMeta&&(delete e.$loki,delete e.meta),s.push(e);else for(n=0;n<i;n++)s.push(a[o[n]]);return s},y.prototype.update=function(t){if("function"!=typeof t)throw new TypeError("Argument is not a function");this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());for(var e,i=this.filteredrows.length,n=this.collection.data,r=0;r<i;r++)this.disableFreeze&&!this.collection.cloneObjects&&this.collection.disableDeltaChangesApi?(t(n[this.filteredrows[r]]),this.collection.update(n[this.filteredrows[r]])):(e=d(n[this.filteredrows[r]],this.collection.cloneMethod),t(e),this.collection.update(e));return this},y.prototype.remove=function(){return this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex()),this.collection.removeBatchByPositions(this.filteredrows),this.filteredrows=[],this},y.prototype.map=function(t,e){var i=this.data(e).map(t);return this.collection=new g("mappedData"),this.collection.insert(i),this.filteredrows=[],this.filterInitialized=!1,this},g.prototype=new u,g.prototype.contructor=g,g.prototype.lokiConsoleWrapper={log:function(){},warn:function(){},error:function(){}},g.prototype.addAutoUpdateObserver=function(t){},g.prototype.removeAutoUpdateObserver=function(t){},g.prototype.prepareFullDocIndex=function(){for(var t=this.data.length,e=new Array(t),i=0;i<t;i+=1)e[i]=i;return e},g.prototype.configureOptions=function(t){t=t||{},t.hasOwnProperty("adaptiveBinaryIndices")&&(this.adaptiveBinaryIndices=t.adaptiveBinaryIndices,this.adaptiveBinaryIndices&&this.ensureAllIndexes())},g.prototype.ensureIndex=function(t,e){if(void 0===e&&(e=!1),null===t||void 0===t)throw new Error("Attempting to set index without an associated property");if((!this.binaryIndices[t]||e||this.binaryIndices[t].dirty)&&(!0!==this.adaptiveBinaryIndices||!this.binaryIndices.hasOwnProperty(t)||e)){var i={name:t,dirty:!0,values:this.prepareFullDocIndex()};this.binaryIndices[t]=i;var n=function(t,e){var i,n,r=!!~t.indexOf(".")&&t.split(".");return function(s,a){if(r?(i=m.getIn(e[s],r,!0),n=m.getIn(e[a],r,!0)):(i=e[s][t],n=e[a][t]),i!==n){if(w.lt(i,n,!1))return-1;if(w.gt(i,n,!1))return 1}return 0}}(t,this.data);i.values.sort(n),i.dirty=!1,this.dirty=!0}},g.prototype.checkAllIndexes=function(t){var e,i=this.binaryIndices,n=[];for(e in i)I.call(i,e)&&(this.checkIndex(e,t)||n.push(e));return n},g.prototype.checkIndex=function(t,e){e=e||{},e.randomSamplingFactor&&!1!==e.randomSampling&&(e.randomSampling=!0),e.randomSamplingFactor=e.randomSamplingFactor||.1,(e.randomSamplingFactor<0||e.randomSamplingFactor>1)&&(e.randomSamplingFactor=.1);var i,n,r,s,a,o=!0;if(!this.binaryIndices.hasOwnProperty(t))throw new Error("called checkIndex on property without an index: "+t);if(this.adaptiveBinaryIndices||this.ensureIndex(t),a=this.binaryIndices[t].values,(s=a.length)!==this.data.length)return e.repair&&this.ensureIndex(t,!0),!1;if(0===s)return!0;var l=-1!==t.indexOf(".");if(1===s)o=0===a[0];else if(e.randomSampling){if(O.$lte(m.getIn(this.data[a[0]],t,l),m.getIn(this.data[a[1]],t,l))||(o=!1),O.$lte(m.getIn(this.data[a[s-2]],t,l),m.getIn(this.data[a[s-1]],t,l))||(o=!1),o)for(n=Math.floor((s-1)*e.randomSamplingFactor),i=0;i<n-1;i++)if(r=Math.floor(Math.random()*(s-1)),!O.$lte(m.getIn(this.data[a[r]],t,l),m.getIn(this.data[a[r+1]],t,l))){o=!1;break}}else for(i=0;i<s-1;i++)if(!O.$lte(m.getIn(this.data[a[i]],t,l),m.getIn(this.data[a[i+1]],t,l))){o=!1;break}return!o&&e.repair&&this.ensureIndex(t,!0),o},g.prototype.getBinaryIndexValues=function(t){var e,i=this.binaryIndices[t].values,n=[];for(e=0;e<i.length;e++)n.push(m.getIn(this.data[i[e]],t,!0));return n},g.prototype.getUniqueIndex=function(t,e){var i=this.constraints.unique[t];return!i&&e?this.ensureUniqueIndex(t):i},g.prototype.ensureUniqueIndex=function(t){var e=this.constraints.unique[t];return e||-1==this.uniqueNames.indexOf(t)&&this.uniqueNames.push(t),this.constraints.unique[t]=e=new b(t),this.data.forEach(function(t){e.set(t)}),e},g.prototype.ensureAllIndexes=function(t){var e,i=this.binaryIndices;for(e in i)I.call(i,e)&&this.ensureIndex(e,t)},g.prototype.flagBinaryIndexesDirty=function(){var t,e=this.binaryIndices;for(t in e)I.call(e,t)&&(e[t].dirty=!0)},g.prototype.flagBinaryIndexDirty=function(t){this.binaryIndices[t]&&(this.binaryIndices[t].dirty=!0)},g.prototype.count=function(t){return t?this.chain().find(t).filteredrows.length:this.data.length},g.prototype.ensureId=function(){if(!this.idIndex){var t=this.data,e=0,i=t.length,n=new Array(i);for(e;e<i;e++)n[e]=t[e].$loki;this.idIndex=n}},g.prototype.findAndUpdate=function(t,e){"function"==typeof t?this.updateWhere(t,e):this.chain().find(t).update(e)},g.prototype.findAndRemove=function(t){this.chain().find(t).remove()},g.prototype.insert=function(t,e){if(!Array.isArray(t))return this.insertOne(t)
;var i,n=[],r=e&&!this.cloneObjects&&this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0;r&&(this.adaptiveBinaryIndices=!1);try{this.emit("pre-insert",t);for(var s=0,a=t.length;s<a;s++){if(!(i=this.insertOne(t[s],!0)))return;n.push(i)}}finally{r&&(this.ensureAllIndexes(),this.adaptiveBinaryIndices=!0)}return this.emit("insert",n),n=this.cloneObjects?d(n,this.cloneMethod):n,1===n.length?n[0]:n},g.prototype.insertOne=function(e,n){var r,s=null;if("object"!=typeof e?s=new TypeError("Document needs to be an object"):null===e&&(s=new TypeError("Object cannot be null")),null!==s)throw this.emit("error",s),s;var a=this.cloneObjects?d(e,this.cloneMethod):e;if(this.disableFreeze||(a=i(a)),this.disableMeta||(void 0===a.meta?a.meta={revision:0,created:0}:this.disableFreeze||(a.meta=i(a.meta))),n||this.emit("pre-insert",a),this.add(a))return this.disableFreeze||t(a),r=this.cloneObjects?d(a,this.cloneMethod):a,n||this.emit("insert",r),this.addAutoUpdateObserver(r),r},g.prototype.clear=function(t){var e=this;if(t=t||{},this.data=[],this.idIndex=null,this.cachedIndex=null,this.cachedBinaryIndex=null,this.cachedData=null,this.maxId=0,this.DynamicViews=[],this.dirty=!0,this.constraints={unique:{},exact:{}},!0===t.removeIndices)this.binaryIndices={},this.uniqueNames=[];else{Object.keys(this.binaryIndices).forEach(function(t){e.binaryIndices[t].dirty=!1,e.binaryIndices[t].values=[]})}},g.prototype.update=function(e){var i,n,r;if(Array.isArray(e)){r=e.length,(i=!this.cloneObjects&&this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0)&&(this.adaptiveBinaryIndices=!1);try{for(n=0;n<r;n+=1)this.update(e[n])}finally{i&&(this.ensureAllIndexes(),this.adaptiveBinaryIndices=!0)}}else{if(!I.call(e,"$loki"))throw new Error("Trying to update unsynced document. Please save the document first by using insert() or addMany()");try{this.startTransaction();var s,a,o,l=this.get(e.$loki,!0),h=this;if(!l)throw new Error("Trying to update a document not in collection.");s=l[0],o=l[1],a=this.cloneObjects||!this.disableDeltaChangesApi&&this.disableFreeze?d(e,this.cloneMethod):e,this.emit("pre-update",e),this.uniqueNames.forEach(function(t){h.getUniqueIndex(t,!0).update(s,a)}),this.data[o]=a,a!==e&&this.addAutoUpdateObserver(e);for(var c=0;c<this.DynamicViews.length;c++)this.DynamicViews[c].evaluateDocument(o,!1);var u;if(this.adaptiveBinaryIndices){var f=this.binaryIndices;for(u in f)this.adaptiveBinaryIndexUpdate(o,u)}else this.flagBinaryIndexesDirty();this.idIndex[o]=a.$loki,this.isIncremental&&this.dirtyIds.push(a.$loki),this.commit(),this.dirty=!0,this.disableFreeze||t(a);var p;return p=this.cloneObjects?d(a,this.cloneMethod):a,this.emit("update",p,s),p}catch(t){throw this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),t}}},g.prototype.add=function(t){if("object"!=typeof t)throw new TypeError("Object being added needs to be an object");if(void 0!==t.$loki)throw new Error("Document is already in collection, please use update()");try{this.startTransaction(),this.maxId++,isNaN(this.maxId)&&(this.maxId=this.data[this.data.length-1].$loki+1);var e=this.maxId;t.$loki=e,this.disableMeta||(t.meta.version=0);for(var i=0,n=this.uniqueNames.length;i<n;i++)this.getUniqueIndex(this.uniqueNames[i],!0).set(t);this.idIndex&&this.idIndex.push(e),this.isIncremental&&this.dirtyIds.push(e),this.data.push(t);var r=this.data.length-1,s=this.DynamicViews.length;for(i=0;i<s;i++)this.DynamicViews[i].evaluateDocument(r,!0);if(this.adaptiveBinaryIndices){var a=this.binaryIndices;for(var o in a)this.adaptiveBinaryIndexInsert(r,o)}else this.flagBinaryIndexesDirty();return this.commit(),this.dirty=!0,this.cloneObjects?d(t,this.cloneMethod):t}catch(t){throw this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),t}},g.prototype.updateWhere=function(t,e){var i,n=this.where(t),r=0;try{for(r;r<n.length;r++)i=e(n[r]),this.update(i)}catch(t){this.rollback(),this.lokiConsoleWrapper.error(t.message)}},g.prototype.removeWhere=function(t){var e;"function"==typeof t?(e=this.data.filter(t),this.remove(e)):this.chain().find(t).remove()},g.prototype.removeDataOnly=function(){this.remove(this.data.slice())},g.prototype.removeBatchByPositions=function(t){var e,i,n,r,s=t.length,a={},o=Object.keys(this.binaryIndices).length,l=Object.keys(this.constraints.unique).length,h=this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0,c=this;try{for(this.startTransaction(),this.ensureId(),n=0;n<s;n++)a[this.idIndex[t[n]]]=!0;if((e=this.DynamicViews.length)>0||o>0||l>0){if(e>0)for(i=0;i<e;i++)this.DynamicViews[i].removeDocument(t);if(this.adaptiveBinaryIndices&&!h){var d,u=this.binaryIndices;for(d in u)this.adaptiveBinaryIndexRemove(t,d)}else this.flagBinaryIndexesDirty();l&&this.uniqueNames.forEach(function(e){var i=c.getUniqueIndex(e);if(i)for(n=0;n<s;n++)r=c.data[t[n]],null!==r[e]&&void 0!==r[e]&&i.remove(r[e])})}if(!this.disableChangesApi||this.events.delete.length>1)for(n=0;n<s;n++)this.emit("delete",this.data[t[n]]);if(this.data=this.data.filter(function(t){return!a[t.$loki]}),this.isIncremental)for(n=0;n<s;n++)this.dirtyIds.push(this.idIndex[t[n]]);this.idIndex=this.idIndex.filter(function(t){return!a[t]}),this.adaptiveBinaryIndices&&h&&(this.adaptiveBinaryIndices=!1,this.ensureAllIndexes(!0),this.adaptiveBinaryIndices=!0),this.commit(),this.dirty=!0}catch(t){return this.rollback(),h&&(this.adaptiveBinaryIndices=!0),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),null}},g.prototype.removeBatch=function(t){var e,i=t.length,n=this.data.length,r={},s=[];for(e=0;e<n;e++)r[this.data[e].$loki]=e;for(e=0;e<i;e++)"object"==typeof t[e]?s.push(r[t[e].$loki]):s.push(r[t[e]]);this.removeBatchByPositions(s)},g.prototype.remove=function(t){if("number"==typeof t&&(t=this.get(t)),"object"!=typeof t)throw new Error("Parameter is not an object");if(Array.isArray(t))return void this.removeBatch(t);if(!I.call(t,"$loki"))throw new Error("Object is not a document stored in the collection");try{this.startTransaction();var n=this.get(t.$loki,!0),r=n[1],s=this;this.uniqueNames.forEach(function(e){if(null!==t[e]&&void 0!==t[e]){var i=s.getUniqueIndex(e);i&&i.remove(t[e])}});for(var a=0;a<this.DynamicViews.length;a++)this.DynamicViews[a].removeDocument(r);if(this.adaptiveBinaryIndices){var o,l=this.binaryIndices;for(o in l)this.adaptiveBinaryIndexRemove(r,o)}else this.flagBinaryIndexesDirty();return this.data.splice(r,1),this.removeAutoUpdateObserver(t),this.idIndex.splice(r,1),this.isIncremental&&this.dirtyIds.push(t.$loki),this.commit(),this.dirty=!0,this.emit("delete",n[0]),this.disableFreeze||(t=i(t)),delete t.$loki,delete t.meta,this.disableFreeze||e(t),t}catch(t){return this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),null}},g.prototype.get=function(t,e){this.idIndex||this.ensureId();var i=e||!1,n=this.idIndex,r=n.length-1,s=0,a=s+r>>1;if(t="number"==typeof t?t:parseInt(t,10),isNaN(t))throw new TypeError("Passed id is not an integer");for(;n[s]<n[r];)a=s+r>>1,n[a]<t?s=a+1:r=a;return r===s&&n[s]===t?i?[this.data[s],s]:this.data[s]:null},g.prototype.getBinaryIndexPosition=function(t,e){var i=m.getIn(this.data[t],e,!0),n=this.binaryIndices[e].values,r=this.calculateRange("$eq",e,i);if(0===r[0]&&-1===r[1])return null;for(var s=r[0],a=r[1],o=s;o<=a;o++)if(n[o]===t)return o;return null},g.prototype.adaptiveBinaryIndexInsert=function(t,e){var i=-1!==e.indexOf("."),n=this.binaryIndices[e].values,r=m.getIn(this.data[t],e,i);!0===this.serializableIndices&&r instanceof Date&&(this.data[t][e]=r.getTime(),r=m.getIn(this.data[t],e));var s=0===n.length?0:this.calculateRangeStart(e,r,!0,i);this.binaryIndices[e].values.splice(s,0,t)},g.prototype.adaptiveBinaryIndexUpdate=function(t,e){var i,n=this.binaryIndices[e].values,r=n.length;for(i=0;i<r&&n[i]!==t;i++);this.binaryIndices[e].values.splice(i,1),this.adaptiveBinaryIndexInsert(t,e)},g.prototype.adaptiveBinaryIndexRemove=function(t,e,i){var n,r,s,a,o,l,h,c=this.binaryIndices[e],d={};if(Array.isArray(t)){if(1!==(a=t.length)){for(s=0;s<a;s++)d[t[s]]=!0;if(c.values=c.values.filter(function(t){return!d[t]}),!0===i)return;var u=t.slice();for(u.sort(function(t,e){return t-e}),n=c.values.length,r=0;r<n;r++){for(o=c.values[r],l=0,s=0;s<a&&o>u[s];s++)l++;c.values[r]-=l}return}t=t[0]}if(null===(h=this.getBinaryIndexPosition(t,e)))return null;if(c.values.splice(h,1),!0!==i)for(n=c.values.length,r=0;r<n;r++)c.values[r]>t&&c.values[r]--},g.prototype.calculateRangeStart=function(t,e,i,n){var r=this.data,s=this.binaryIndices[t].values,a=0,o=s.length-1,l=0;if(0===s.length)return-1;for(m.getIn(r[s[a]],t,n),m.getIn(r[s[o]],t,n);a<o;)l=a+o>>1,w.lt(m.getIn(r[s[l]],t,n),e,!1)?a=l+1:o=l;var h=a;return w.aeq(e,m.getIn(r[s[h]],t,n))?h:w.lt(e,m.getIn(r[s[h]],t,n),!1)?i?h:h-1:i?h+1:h},g.prototype.calculateRangeEnd=function(t,e,i){var n=this.data,r=this.binaryIndices[t].values,s=0,a=r.length-1,o=0;if(0===r.length)return-1;for(m.getIn(n[r[s]],t,i),m.getIn(n[r[a]],t,i);s<a;)o=s+a>>1,w.lt(e,m.getIn(n[r[o]],t,i),!1)?a=o:s=o+1;var l=a;return w.aeq(e,m.getIn(n[r[l]],t,i))?l:w.gt(e,m.getIn(n[r[l]],t,i),!1)?l+1:w.aeq(e,m.getIn(n[r[l-1]],t,i))?l-1:l},g.prototype.calculateRange=function(t,e,i){var n,r,s,a=this.data,o=this.binaryIndices[e].values,l=o.length-1;if(0===a.length)return[0,-1];var h=-1!==e.indexOf("."),c=m.getIn(a[o[0]],e,h),d=m.getIn(a[o[l]],e,h);switch(t){case"$eq":case"$aeq":case"$dteq":if(w.lt(i,c,!1)||w.gt(i,d,!1))return[0,-1];break;case"$gt":if(w.gt(i,d,!0))return[0,-1];if(w.gt(c,i,!1))return[0,l];break;case"$gte":if(w.gt(i,d,!1))return[0,-1];if(w.gt(c,i,!0))return[0,l];break;case"$lt":if(w.lt(i,c,!0))return[0,-1];if(w.lt(d,i,!1))return[0,l];break;case"$lte":if(w.lt(i,c,!1))return[0,-1];if(w.lt(d,i,!0))return[0,l];break;case"$between":return w.gt(i[0],d,!1)?[0,-1]:w.lt(i[1],c,!1)?[0,-1]:(n=this.calculateRangeStart(e,i[0],!1,h),s=this.calculateRangeEnd(e,i[1],h),n<0&&n++,s>l&&s--,w.gt(m.getIn(a[o[n]],e,h),i[0],!0)||n++,w.lt(m.getIn(a[o[s]],e,h),i[1],!0)||s--,s<n?[0,-1]:[n,s]);case"$in":for(var u=[],f=[],p=0,y=i.length;p<y;p++)for(var v=this.calculateRange("$eq",e,i[p]),g=v[0];g<=v[1];g++)void 0===u[g]&&(u[g]=!0,f.push(g));return f}switch(t){case"$eq":case"$aeq":case"$dteq":case"$gte":case"$lt":n=this.calculateRangeStart(e,i,!1,h),r=m.getIn(a[o[n]],e,h)}switch(t){case"$eq":case"$aeq":case"$dteq":case"$lte":case"$gt":s=this.calculateRangeEnd(e,i,h),m.getIn(a[o[s]],e,h)}switch(t){case"$eq":case"$aeq":case"$dteq":return w.aeq(r,i)?[n,s]:[0,-1];case"$gt":return w.aeq(m.getIn(a[o[s]],e,h),i)?[s+1,l]:[s,l];case"$gte":return w.aeq(m.getIn(a[o[n]],e,h),i)?[n,l]:[n+1,l];case"$lt":return w.aeq(m.getIn(a[o[n]],e,h),i)?[0,n-1]:[0,n];case"$lte":return w.aeq(m.getIn(a[o[s]],e,h),i)?[0,s]:[0,s-1];default:return[0,a.length-1]}},g.prototype.by=function(t,e){var i;if(void 0===e)return i=this,function(e){return i.by(t,e)};var n=this.getUniqueIndex(t,!0).get(e);return this.cloneObjects?d(n,this.cloneMethod):n},g.prototype.findOne=function(t){t=t||{};var e=this.chain().find(t,!0).data();return Array.isArray(e)&&0===e.length?null:this.cloneObjects?d(e[0],this.cloneMethod):e[0]},g.prototype.chain=function(t,e){var i=new y(this);return void 0===t?i:i.transform(t,e)},g.prototype.find=function(t){return this.chain().find(t).data()},g.prototype.findOneUnindexed=function(t,e){for(var i=this.data.length;i--;)if(m.getIn(this.data[i],t,!0)===e)return this.data[i];return null},g.prototype.startTransaction=function(){},g.prototype.commit=function(){},g.prototype.rollback=function(){},g.prototype.where=function(t){return this.chain().where(t).data()},b.prototype.keyMap={},b.prototype.lokiMap={},b.prototype.set=function(t){var e=t[this.field];if(null!==e&&void 0!==e){if(this.keyMap[e])throw new Error("Duplicate key for property "+this.field+": "+e);this.keyMap[e]=t,this.lokiMap[t.$loki]=e}},b.prototype.get=function(t){return this.keyMap[t]},b.prototype.byId=function(t){return this.keyMap[this.lokiMap[t]]},b.prototype.update=function(t,e){if(this.lokiMap[t.$loki]!==e[this.field]){var i=this.lokiMap[t.$loki];this.set(e),this.keyMap[i]=void 0}else this.keyMap[t[this.field]]=e},b.prototype.remove=function(t){var e=this.keyMap[t];if(null===e||void 0===e)throw new Error("Key is not in unique index: "+this.field);this.keyMap[t]=void 0,this.lokiMap[e.$loki]=void 0},b.prototype.clear=function(){this.keyMap=Object.create(null),this.lokiMap=Object.create(null)},f.deepFreeze=t,f.freeze=e,f.unFreeze=i,f.LokiOps=O,f.Collection=g,f.Resultset=y,f.LokiMemoryAdapter=p,f.aeq=n,f.lt=r,f.gt=s,f.Comparators=w,f}()});
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.loki=e()}(this,function(){return function(){"use strict";function t(i){var n,r;if(Array.isArray(i)){for(r=0;r<i.length;r++)t(i[r]);e(i)}else if(null!==i&&"object"==typeof i){for(n in i)i.hasOwnProperty(n)&&t(i[n]);e(i)}}function e(t){Object.isFrozen(t)||Object.freeze(t)}function i(t){return Object.isFrozen(t)?d(t,"shallow"):t}function n(t,e){var i,n,r,s;if(t===e)return!0;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:r=1;break;case!1:r=3;break;case!0:r=4;break;case"":r=5;break;default:r=t===t?9:0}switch(e){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=e===e?9:0}if(9!==r||9!==s)return r===s}return i=Number(t),n=Number(e),i===i||n===n?i===n:(i=t.toString(),n=e.toString(),i==n)}function r(t,e,i){var n,r,s,a;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=t===t?9:0}switch(e){case void 0:case null:a=1;break;case!1:a=3;break;case!0:a=4;break;case"":a=5;break;default:a=e===e?9:0}if(9!==s||9!==a)return s===a?i:s<a}return n=Number(t),r=Number(e),n===n&&r===r?n<r||!(n>r)&&i:n===n&&r!==r||(r!==r||n===n)&&(t<e||!(t>e)&&(t==e?i:(n=t.toString(),r=e.toString(),n<r||n==r&&i)))}function s(t,e,i){var n,r,s,a;if(!t||!e||!0===t||!0===e||t!==t||e!==e){switch(t){case void 0:case null:s=1;break;case!1:s=3;break;case!0:s=4;break;case"":s=5;break;default:s=t===t?9:0}switch(e){case void 0:case null:a=1;break;case!1:a=3;break;case!0:a=4;break;case"":a=5;break;default:a=e===e?9:0}if(9!==s||9!==a)return s===a?i:s>a}return n=Number(t),r=Number(e),n===n&&r===r?n>r||!(n<r)&&i:(n!==n||r===r)&&(r===r&&n!==n||(t>e||!(t<e)&&(t==e?i:(n=t.toString(),r=e.toString(),n>r||n==r&&i))))}function a(t,e,i){return w.aeq(t,e)?0:w.lt(t,e,!1)?i?1:-1:w.gt(t,e,!1)?i?-1:1:0}function o(t,e,i){for(var n,r,s,o,l,h=0,c=0,d=t.length;c<d;c++)if(n=t[c],r=n[0],~r.indexOf(".")?(l=r.split("."),s=m.getIn(e,l,!0),o=m.getIn(i,l,!0)):(s=e[r],o=i[r]),0!==(h=a(s,o,n[1])))return h;return 0}function l(t,e,i,n,r,s){var a,o=s||0,h=e[o],c=!1;if("object"==typeof t&&h in t&&(a=t[h]),o+1>=e.length)c=i(a,n,r);else if(Array.isArray(a))for(var d=0,u=a.length;d<u&&!0!==(c=l(a[d],e,i,n,r,o+1));d+=1);else c=l(a,e,i,n,r,o+1);return c}function h(t){return"string"==typeof t||Array.isArray(t)?function(e){return-1!==t.indexOf(e)}:"object"==typeof t&&null!==t?function(e){return I.call(t,e)}:null}function c(t,e,i){for(var n in e)if(I.call(e,n))return O[n](t,e[n],i);return!1}function d(t,e){if(null===t||void 0===t)return null;var i,n=e||"parse-stringify";switch(n){case"parse-stringify":i=JSON.parse(JSON.stringify(t))}return i}function u(){}function f(t,e){this.filename=t||"loki.db",this.collections=[],this.databaseVersion=1.5,this.engineVersion=1.5,this.autosave=!1,this.autosaveInterval=5e3,this.autosaveHandle=null,this.throttledSaves=!0,this.options={},this.persistenceMethod=null,this.persistenceAdapter=null,this.throttledSavePending=!1,this.throttledCallbacks=[],this.verbose=!(!e||!e.hasOwnProperty("verbose"))&&e.verbose,this.events={init:[],loaded:[],flushChanges:[],close:[],changes:[],warning:[]},this.configureOptions(e,!0)}function p(t){this.hashStore={},this.options=t||{},this.options.hasOwnProperty("asyncResponses")||(this.options.asyncResponses=!1),this.options.hasOwnProperty("asyncTimeout")||(this.options.asyncTimeout=50)}function y(t,e){return e=e||{},this.collection=t,this.filteredrows=[],this.filterInitialized=!1,this}function v(t,e){if("$regex"===t)Array.isArray(e)?e=new RegExp(e[0],e[1]):e instanceof RegExp||(e=new RegExp(e));else if("object"==typeof e)for(var i in e)"$regex"!==i&&"object"!=typeof e[i]||(e[i]=v(i,e[i]));return e}function g(t,e){this.name=t,this.data=[],this.idIndex=null,this.binaryIndices={},this.constraints={unique:{},exact:{}},this.uniqueNames=[],this.transforms={},this.objType=t,this.dirty=!0,this.cachedIndex=null,this.cachedBinaryIndex=null,this.cachedData=null;var i=this;e=e||{},e.hasOwnProperty("unique")&&(Array.isArray(e.unique)||(e.unique=[e.unique]),e.unique.forEach(function(t){i.uniqueNames.push(t)})),this.adaptiveBinaryIndices=!e.hasOwnProperty("adaptiveBinaryIndices")||e.adaptiveBinaryIndices,this.transactional=!!e.hasOwnProperty("transactional")&&e.transactional,this.cloneObjects=!!e.hasOwnProperty("clone")&&e.clone,this.cloneMethod=e.hasOwnProperty("cloneMethod")?e.cloneMethod:"parse-stringify",this.asyncListeners=!!e.hasOwnProperty("asyncListeners")&&e.asyncListeners,this.disableMeta=!!e.hasOwnProperty("disableMeta")&&e.disableMeta,this.disableChangesApi=!e.hasOwnProperty("disableChangesApi")||e.disableChangesApi,this.disableDeltaChangesApi=!e.hasOwnProperty("disableDeltaChangesApi")||e.disableDeltaChangesApi,this.disableChangesApi&&(this.disableDeltaChangesApi=!0),this.autoupdate=!!e.hasOwnProperty("autoupdate")&&e.autoupdate,this.serializableIndices=!e.hasOwnProperty("serializableIndices")||e.serializableIndices,this.disableFreeze=!e.hasOwnProperty("disableFreeze")||e.disableFreeze,this.maxId=0,this.DynamicViews=[],this.events={insert:[],update:[],"pre-insert":[],"pre-update":[],close:[],flushbuffer:[],error:[],delete:[],warning:[]},this.changes=[],this.dirtyIds=[];var n=[];if(e&&e.indices)if("[object Array]"===Object.prototype.toString.call(e.indices))n=e.indices;else{if("string"!=typeof e.indices)throw new TypeError("Indices needs to be a string or an array of strings");n=[e.indices]}for(var r=0;r<n.length;r++)this.ensureIndex(n[r]);this.on("warning",function(t){i.lokiConsoleWrapper.warn(t)})}function b(t){this.field=t,this.keyMap=Object.create(null),this.lokiMap=Object.create(null)}var I=Object.prototype.hasOwnProperty,m={copyProperties:function(t,e){var i;for(i in t)e[i]=t[i]},getIn:function(t,e,i){if(null!=t){if(!i)return t[e];if("string"==typeof e&&(e=e.split(".")),!Array.isArray(e))throw new Error("path must be a string or array. Found "+typeof e);for(var n=0,r=e.length;null!=t&&n<r;)t=t[e[n++]];return n&&n==r?t:void 0}}},w={aeq:n,lt:r,gt:s},O={$eq:function(t,e){return t===e},$aeq:function(t,e){return t==e},$ne:function(t,e){return e!==e?t===t:t!==e},$dteq:function(t,e){return w.aeq(t,e)},$gt:function(t,e){return w.gt(t,e,!1)},$gte:function(t,e){return w.gt(t,e,!0)},$lt:function(t,e){return w.lt(t,e,!1)},$lte:function(t,e){return w.lt(t,e,!0)},$jgt:function(t,e){return t>e},$jgte:function(t,e){return t>=e},$jlt:function(t,e){return t<e},$jlte:function(t,e){return t<=e},$between:function(t,e){return void 0!==t&&null!==t&&(w.gt(t,e[0],!0)&&w.lt(t,e[1],!0))},$jbetween:function(t,e){return void 0!==t&&null!==t&&(t>=e[0]&&t<=e[1])},$in:function(t,e){return-1!==e.indexOf(t)},$inSet:function(t,e){return e.has(t)},$nin:function(t,e){return-1===e.indexOf(t)},$keyin:function(t,e){return t in e},$nkeyin:function(t,e){return!(t in e)},$definedin:function(t,e){return void 0!==e[t]},$undefinedin:function(t,e){return void 0===e[t]},$regex:function(t,e){return e.test(t)},$containsString:function(t,e){return"string"==typeof t&&-1!==t.indexOf(e)},$containsNone:function(t,e){return!O.$containsAny(t,e)},$containsAny:function(t,e){var i=h(t);return null!==i&&(Array.isArray(e)?e.some(i):i(e))},$contains:function(t,e){var i=h(t);return null!==i&&(Array.isArray(e)?e.every(i):i(e))},$elemMatch:function(t,e){return!!Array.isArray(t)&&t.some(function(t){return Object.keys(e).every(function(i){var n=e[i];return"object"==typeof n&&n||(n={$eq:n}),-1!==i.indexOf(".")?l(t,i.split("."),c,e[i],t):c(t[i],n,t)})})},$type:function(t,e,i){var n=typeof t;return"object"===n&&(Array.isArray(t)?n="array":t instanceof Date&&(n="date")),"object"!=typeof e?n===e:c(n,e,i)},$finite:function(t,e){return e===isFinite(t)},$size:function(t,e,i){return!!Array.isArray(t)&&("object"!=typeof e?t.length===e:c(t.length,e,i))},$len:function(t,e,i){return"string"==typeof t&&("object"!=typeof e?t.length===e:c(t.length,e,i))},$where:function(t,e){return!0===e(t)},$not:function(t,e,i){return!c(t,e,i)},$and:function(t,e,i){for(var n=0,r=e.length;n<r;n+=1)if(!c(t,e[n],i))return!1;return!0},$or:function(t,e,i){for(var n=0,r=e.length;n<r;n+=1)if(c(t,e[n],i))return!0;return!1},$exists:function(t,e){return e?void 0!==t:void 0===t}};["$eq","$aeq","$ne","$dteq","$gt","$gte","$lt","$lte","$jgt","$jgte","$jlt","$jlte","$type"].forEach(function(t){var e=O[t];O["$"+t]=function(t,i,n){if("string"==typeof i)return e(t,n[i]);if("function"==typeof i)return e(t,i(n));throw new Error("Invalid argument to $$ matcher")}});var $={$eq:O.$eq,$aeq:!0,$dteq:!0,$gt:!0,$gte:!0,$lt:!0,$lte:!0,$in:!0,$between:!0};return u.prototype.events={},u.prototype.asyncListeners=!1,u.prototype.on=function(t,e){var i,n=this;return Array.isArray(t)?(t.forEach(function(t){n.on(t,e)}),e):(i=this.events[t],i||(i=this.events[t]=[]),i.push(e),e)},u.prototype.emit=function(t){var e,i=this;if(!t||!this.events[t])throw new Error("No event "+t+" defined");this.events[t].length&&(e=Array.prototype.slice.call(arguments,1),this.events[t].forEach(function(t){i.asyncListeners?setTimeout(function(){t.apply(i,e)},1):t.apply(i,e)}))},u.prototype.addListener=u.prototype.on,u.prototype.removeListener=function(t,e){var i=this;if(Array.isArray(t))return void t.forEach(function(t){i.removeListener(t,e)});if(this.events[t]){var n=this.events[t];n.splice(n.indexOf(e),1)}},f.prototype=new u,f.prototype.constructor=f,f.prototype.configureOptions=function(t,e){var i={NODEJS:"fs",BROWSER:"localStorage",CORDOVA:"localStorage",MEMORY:"memory"},n={memory:p};if(this.options={},this.persistenceMethod=null,this.persistenceAdapter=null,void 0!==t){if(this.options=t,this.options.hasOwnProperty("persistenceMethod")&&"function"==typeof n[t.persistenceMethod]&&(this.persistenceMethod=t.persistenceMethod,this.persistenceAdapter=new n[t.persistenceMethod]),this.options.hasOwnProperty("adapter")&&(this.persistenceMethod="adapter",this.persistenceAdapter=t.adapter,this.options.adapter=null,this.isIncremental="incremental"===this.persistenceAdapter.mode),t.autoload&&e){var r=this;setTimeout(function(){r.loadDatabase(t,t.autoloadCallback)},1)}this.options.hasOwnProperty("autosaveInterval")&&(this.autosaveDisable(),this.autosaveInterval=parseInt(this.options.autosaveInterval,10)),this.options.hasOwnProperty("autosave")&&this.options.autosave&&(this.autosaveDisable(),this.autosave=!0,this.options.hasOwnProperty("autosaveCallback")?this.autosaveEnable(t,t.autosaveCallback):this.autosaveEnable()),this.options.hasOwnProperty("throttledSaves")&&(this.throttledSaves=this.options.throttledSaves)}this.options.hasOwnProperty("serializationMethod")||(this.options.serializationMethod="normal"),this.options.hasOwnProperty("destructureDelimiter")||(this.options.destructureDelimiter="$<\n"),null===this.persistenceAdapter&&(this.persistenceMethod=i[this.ENV],this.persistenceMethod&&(this.persistenceAdapter=new n[this.persistenceMethod]))},f.prototype.copy=function(t){var e,i,n=new f(this.filename,{env:"NA"});if(t=t||{},n.loadJSONObject(this,{retainDirtyFlags:!0}),t.hasOwnProperty("removeNonSerializable")&&!0===t.removeNonSerializable)for(n.autosaveHandle=null,n.persistenceAdapter=null,e=n.collections.length,i=0;i<e;i++)n.collections[i].constraints=null,n.collections[i].ttl=null;return n},f.prototype.addCollection=function(t,e){var i,n=this.collections.length;for(i=0;i<n;i+=1)if(this.collections[i].name===t)return this.collections[i];var r=new g(t,e);return r.isIncremental=this.isIncremental,this.collections.push(r),this.verbose&&(r.lokiConsoleWrapper=console),r},f.prototype.loadCollection=function(t){if(!t.name)throw new Error("Collection must have a name property to be loaded");this.collections.push(t)},f.prototype.getCollection=function(t){var e,i=this.collections.length;for(e=0;e<i;e+=1)if(this.collections[e].name===t)return this.collections[e];return this.emit("warning","collection "+t+" not found"),null},f.prototype.renameCollection=function(t,e){var i=this.getCollection(t);return i&&(i.name=e),i},f.prototype.removeCollection=function(t){var e,i=this.collections.length;for(e=0;e<i;e+=1)if(this.collections[e].name===t){var n=new g(t,{}),r=this.collections[e];for(var s in r)r.hasOwnProperty(s)&&n.hasOwnProperty(s)&&(r[s]=n[s]);return void this.collections.splice(e,1)}},f.prototype.getName=function(){return this.name},f.prototype.serializeReplacer=function(t,e){switch(t){case"autosaveHandle":case"persistenceAdapter":case"constraints":case"ttl":return null;case"throttledSavePending":case"throttledCallbacks":return;case"lokiConsoleWrapper":return null;default:return e}},f.prototype.serialize=function(t){switch(t=t||{},t.hasOwnProperty("serializationMethod")||(t.serializationMethod=this.options.serializationMethod),t.serializationMethod){case"normal":return JSON.stringify(this,this.serializeReplacer);case"pretty":return JSON.stringify(this,this.serializeReplacer,2);case"destructured":return this.serializeDestructured();default:return JSON.stringify(this,this.serializeReplacer)}},f.prototype.toJson=f.prototype.serialize,f.prototype.loadJSON=function(t,e){var i;if(0===t.length)i={};else switch(this.options.serializationMethod){case"normal":case"pretty":i=JSON.parse(t);break;case"destructured":i=this.deserializeDestructured(t);break;default:i=JSON.parse(t)}this.loadJSONObject(i,e)},f.prototype.loadJSONObject=function(e,i){var n,r,s,a,o,l,h=0,c=e.collections?e.collections.length:0;for(this.name=e.name,e.hasOwnProperty("throttledSaves")&&i&&!i.hasOwnProperty("throttledSaves")&&(this.throttledSaves=e.throttledSaves),this.collections=[],h;h<c;h+=1){if(n=e.collections[h],r=this.addCollection(n.name,{disableChangesApi:n.disableChangesApi,disableDeltaChangesApi:n.disableDeltaChangesApi,disableMeta:n.disableMeta,disableFreeze:!n.hasOwnProperty("disableFreeze")||n.disableFreeze}),r.adaptiveBinaryIndices=!!n.hasOwnProperty("adaptiveBinaryIndices")&&!0===n.adaptiveBinaryIndices,r.transactional=n.transactional,r.asyncListeners=n.asyncListeners,r.cloneObjects=n.cloneObjects,r.cloneMethod=n.cloneMethod||"parse-stringify",r.autoupdate=n.autoupdate,r.changes=n.changes,r.dirtyIds=n.dirtyIds||[],i&&!0===i.retainDirtyFlags?r.dirty=n.dirty:r.dirty=!1,n.getData){if(i&&i.hasOwnProperty(n.name)||!r.disableFreeze||r.autoupdate)throw new Error("this collection cannot be loaded lazily: "+n.name);r.getData=n.getData,Object.defineProperty(r,"data",{get:function(){var t=this.getData();return this.getData=null,Object.defineProperty(this,"data",{value:t}),t}})}else if(s=n.data.length,a=0,i&&i.hasOwnProperty(n.name))for(o=function(t){var e,n=i[t.name];return n.proto?(e=n.inflate||m.copyProperties,function(t){var i=new n.proto;return e(t,i),i}):n.inflate}(n),a;a<s;a++)l=o(n.data[a]),r.data[a]=l,r.addAutoUpdateObserver(l),r.disableFreeze||t(r.data[a]);else for(a;a<s;a++)r.data[a]=n.data[a],r.addAutoUpdateObserver(r.data[a]),r.disableFreeze||t(r.data[a]);r.maxId=void 0===n.maxId?0:n.maxId,void 0!==n.binaryIndices&&(r.binaryIndices=n.binaryIndices),void 0!==n.transforms&&(r.transforms=n.transforms),r.uniqueNames=[],n.hasOwnProperty("uniqueNames")&&(r.uniqueNames=n.uniqueNames),e.databaseVersion<1.5&&(r.ensureAllIndexes(!0),r.dirty=!0)}},f.prototype.close=function(t){this.autosave&&(this.autosaveDisable(),this.autosaveDirty()&&(this.saveDatabase(t),t=void 0)),t&&this.on("close",t),this.emit("close")},p.prototype.loadDatabase=function(t,e){var i=this;this.options.asyncResponses?setTimeout(function(){e(i.hashStore.hasOwnProperty(t)?i.hashStore[t].value:null)},this.options.asyncTimeout):e(this.hashStore.hasOwnProperty(t)?this.hashStore[t].value:null)},p.prototype.saveDatabase=function(t,e,i){var n,r=this;this.options.asyncResponses?setTimeout(function(){n=r.hashStore.hasOwnProperty(t)?r.hashStore[t].savecount:0,r.hashStore[t]={savecount:n+1,lastsave:new Date,value:e},i()},this.options.asyncTimeout):(n=this.hashStore.hasOwnProperty(t)?this.hashStore[t].savecount:0,this.hashStore[t]={savecount:n+1,lastsave:new Date,value:e},i())},p.prototype.deleteDatabase=function(t,e){this.hashStore.hasOwnProperty(t)&&delete this.hashStore[t],"function"==typeof e&&e()},f.prototype.throttledSaveDrain=function(t,e){var i=this,n=(new Date).getTime();if(this.throttledSaves||t(!0),e=e||{},e.hasOwnProperty("recursiveWait")||(e.recursiveWait=!0),e.hasOwnProperty("recursiveWaitLimit")||(e.recursiveWaitLimit=!1),e.hasOwnProperty("recursiveWaitLimitDuration")||(e.recursiveWaitLimitDuration=2e3),e.hasOwnProperty("started")||(e.started=(new Date).getTime()),this.throttledSaves&&this.throttledSavePending){if(!e.recursiveWait)return void this.throttledCallbacks.push(t);this.throttledCallbacks.push(function(){return i.throttledSavePending?e.recursiveWaitLimit&&n-e.started>e.recursiveWaitLimitDuration?void t(!1):void i.throttledSaveDrain(t,e):void t(!0)})}else t(!0)},f.prototype.loadDatabaseInternal=function(t,e){var i=e||function(t,e){if(t)throw t},n=this;null!==this.persistenceAdapter?this.persistenceAdapter.loadDatabase(this.filename,function(e){if("string"==typeof e){var r=!1;try{n.loadJSON(e,t||{}),r=!0}catch(t){i(t)}r&&(i(null),n.emit("loaded","database "+n.filename+" loaded"))}else{if(!e)return i(null),void n.emit("loaded","empty database "+n.filename+" loaded");if(e instanceof Error)return void i(e);if("object"==typeof e)return n.loadJSONObject(e,t||{}),i(null),void n.emit("loaded","database "+n.filename+" loaded");i("unexpected adapter response : "+e)}}):i(new Error("persistenceAdapter not configured"))},f.prototype.loadDatabase=function(t,e){var i=this;if(!this.throttledSaves)return void this.loadDatabaseInternal(t,e);this.throttledSaveDrain(function(n){if(n)return i.throttledSavePending=!0,void i.loadDatabaseInternal(t,function(t){0===i.throttledCallbacks.length?i.throttledSavePending=!1:i.saveDatabase(),"function"==typeof e&&e(t)});"function"==typeof e&&e(new Error("Unable to pause save throttling long enough to read database"))},t)},f.prototype.saveDatabaseInternal=function(t){var e=t||function(t){if(t)throw t},i=this;if(!this.persistenceAdapter)return void e(new Error("persistenceAdapter not configured"));if("incremental"===this.persistenceAdapter.mode){var n;this.ignoreAutosave=!0,this.persistenceAdapter.saveDatabase(this.filename,function(){if(i.ignoreAutosave=!1,n)return void e(new Error("adapter error - getLokiCopy called more than once"));var t=i.copy({removeNonSerializable:!0});return n=i.collections.map(function(t){return[t.dirty,t.dirtyIds]}),i.collections.forEach(function(t){t.dirty=!1,t.dirtyIds=[]}),t},function(t){i.ignoreAutosave=!1,t&&n&&i.collections.forEach(function(t,e){var i=n[e];t.dirty=t.dirty||i[0],t.dirtyIds=t.dirtyIds.concat(i[1])}),e(t)})}else"reference"===this.persistenceAdapter.mode&&"function"==typeof this.persistenceAdapter.exportDatabase?this.persistenceAdapter.exportDatabase(this.filename,this.copy({removeNonSerializable:!0}),function(t){i.autosaveClearFlags(),e(t)}):(this.autosaveClearFlags(),this.persistenceAdapter.saveDatabase(this.filename,this.serialize(),function(t){e(t)}))},f.prototype.saveDatabase=function(t){if(!this.throttledSaves)return void this.saveDatabaseInternal(t);if(this.throttledSavePending)return void this.throttledCallbacks.push(t);var e=this.throttledCallbacks;this.throttledCallbacks=[],e.unshift(t),this.throttledSavePending=!0;var i=this;this.saveDatabaseInternal(function(t){i.throttledSavePending=!1,e.forEach(function(e){"function"==typeof e&&setTimeout(function(){e(t)},1)}),i.throttledCallbacks.length>0&&i.saveDatabase()})},f.prototype.save=f.prototype.saveDatabase,f.prototype.deleteDatabase=function(t,e){var i=e||function(t,e){if(t)throw t};"function"!=typeof t||e||(i=t),null!==this.persistenceAdapter?this.persistenceAdapter.deleteDatabase(this.filename,function(t){i(t)}):i(new Error("persistenceAdapter not configured"))},f.prototype.autosaveDirty=function(){for(var t=0;t<this.collections.length;t++)if(this.collections[t].dirty)return!0;return!1},f.prototype.autosaveClearFlags=function(){for(var t=0;t<this.collections.length;t++)this.collections[t].dirty=!1},f.prototype.autosaveEnable=function(t,e){this.autosave=!0;var i=5e3,n=this;void 0!==this.autosaveInterval&&null!==this.autosaveInterval&&(i=this.autosaveInterval),this.autosaveHandle=setInterval(function(){n.autosaveDirty()&&!n.ignoreAutosave&&n.saveDatabase(e)},i)},f.prototype.autosaveDisable=function(){void 0!==this.autosaveHandle&&null!==this.autosaveHandle&&(clearInterval(this.autosaveHandle),this.autosaveHandle=null)},y.prototype.reset=function(){return this.filteredrows.length>0&&(this.filteredrows=[]),this.filterInitialized=!1,this},y.prototype.toJSON=function(){var t=this.copy();return t.collection=null,t},y.prototype.limit=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=new y(this.collection);return e.filteredrows=this.filteredrows.slice(0,t),e.filterInitialized=!0,e},y.prototype.offset=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=new y(this.collection);return e.filteredrows=this.filteredrows.slice(t),e.filterInitialized=!0,e},y.prototype.copy=function(){var t=new y(this.collection);return this.filteredrows.length>0&&(t.filteredrows=this.filteredrows.slice()),t.filterInitialized=this.filterInitialized,t},y.prototype.branch=y.prototype.copy,y.prototype.sort=function(t){this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var e=function(t,e){return function(i,n){return t(e[i],e[n])}}(t,this.collection.data);return this.filteredrows.sort(e),this},y.prototype.simplesort=function(t,e){var i,n=10,r=this.collection.data.length,s=this.filteredrows.length,o=this.collection.binaryIndices.hasOwnProperty(t);if(void 0!==e&&!1!==e||(e={desc:!1}),!0===e&&(e={desc:!0}),0===s){if(this.filterInitialized)return this;if(this.collection.binaryIndices.hasOwnProperty(t))return this.collection.ensureIndex(t),this.filteredrows=this.collection.binaryIndices[t].values.slice(0),e.desc&&this.filteredrows.reverse(),this;this.filteredrows=this.collection.prepareFullDocIndex()}else if(!e.disableIndexIntersect&&o&&(i=r/s,e.useJavascriptSorting&&(n=6),i<=n||e.forceIndexIntersect)){var l,h=this.filteredrows,c={};for(l=0;l<s;l++)c[h[l]]=!0;var d=this.collection.binaryIndices[t].values;return this.filteredrows=d.filter(function(t){return c[t]}),e.desc&&this.filteredrows.reverse(),this}if(e.useJavascriptSorting)return this.sort(function(e,i){return e[t]===i[t]?0:e[t]>i[t]?1:e[t]<i[t]?-1:void 0});var u=function(t,e,i){var n,r,s;return function(o,l){return~t.indexOf(".")?(s=t.split("."),n=m.getIn(i[o],s,!0),r=m.getIn(i[l],s,!0)):(n=i[o][t],r=i[l][t]),a(n,r,e)}}(t,e.desc,this.collection.data);return this.filteredrows.sort(u),this},y.prototype.compoundsort=function(t){if(0===t.length)throw new Error("Invalid call to compoundsort, need at least one property");var e;if(1===t.length)return e=t[0],Array.isArray(e)?this.simplesort(e[0],e[1]):this.simplesort(e,!1);for(var i=0,n=t.length;i<n;i+=1)e=t[i],Array.isArray(e)||(t[i]=[e,!1]);this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());var r=function(t,e){return function(i,n){return o(t,e[i],e[n])}}(t,this.collection.data);return this.filteredrows.sort(r),this},y.prototype.findOr=function(t){for(var e=null,i=0,n=0,r=[],s=[],a=0,o=(this.count(),0),l=t.length;o<l;o++)for(e=this.branch().find(t[o]).filteredrows,n=e.length,i=0;i<n;i++)a=e[i],void 0===s[a]&&(s[a]=!0,r.push(a));return this.filteredrows=r,this.filterInitialized=!0,this},y.prototype.$or=y.prototype.findOr,y.prototype.findAnd=function(t){for(var e=0,i=t.length;e<i;e++){if(0===this.count())return this;this.find(t[e])}return this},y.prototype.$and=y.prototype.findAnd,y.prototype.find=function(t,e){if(0===this.collection.data.length)return this.filteredrows=[],this.filterInitialized=!0,this;var i,n,r,s,a,o,h,c=t||"getAll",d=!1,u=[],f=[],p=null;if(e=e||!1,"object"==typeof c){for(i in c)s={},s[i]=c[i],f.push(s),I.call(c,i)&&(n=i,r=c[i]);if(f.length>1)return this.find({$and:f},e)}if(!n||"getAll"===c)return e&&(this.filterInitialized?this.filteredrows=this.filteredrows.slice(0,1):(this.filteredrows=this.collection.data.length>0?[0]:[],this.filterInitialized=!0)),this;if("$and"===n||"$or"===n)return this[n](r),e&&this.filteredrows.length>1&&(this.filteredrows=this.filteredrows.slice(0,1)),this;if(null===r||"object"!=typeof r||r instanceof Date)a="$eq",o=r;else{if("object"!=typeof r)throw new Error("Do not know what you want to do.");for(h in r)if(I.call(r,h)){a=h,o=r[h];break}}"$regex"!==a&&"object"!=typeof o||(o=v(a,o));var y=-1!==n.indexOf(".");!this.filterInitialized&&this.collection.binaryIndices[n]&&$[a]&&(!0!==this.collection.adaptiveBinaryIndices&&this.collection.ensureIndex(n),d=!0,p=this.collection.binaryIndices[n]),!d&&"$in"===a&&Array.isArray(o)&&"undefined"!=typeof Set&&(o=new Set(o),a="$inSet");var g,b,w=O[a],k=this.collection.data,A=0,x=0,D=0;if(this.filterInitialized){if(g=this.filteredrows,x=g.length,y){for(n=n.split("."),A=0;A<x;A++)if(D=g[A],b=k[D],l(b,n,w,o,b)&&(u.push(D),e))return this.filteredrows=u,this}else for(A=0;A<x;A++)if(D=g[A],b=k[D],w(b[n],o,b)&&(u.push(D),e))return this.filteredrows=u,this}else if(d){var S=this.collection.calculateRange(a,n,o);if("$in"!==a){for(A=S[0];A<=S[1];A++)if(!0!==$[a]){if($[a](m.getIn(k[p.values[A]],n,y),o)&&(u.push(p.values[A]),e))return this.filteredrows=u,this.filterInitialized=!0,this}else if(u.push(p.values[A]),e)return this.filteredrows=u,this.filterInitialized=!0,this}else for(A=0,x=S.length;A<x;A++)if(u.push(p.values[S[A]]),e)return this.filteredrows=u,this.filterInitialized=!0,this}else if(x=k.length,y){for(n=n.split("."),A=0;A<x;A++)if(b=k[A],l(b,n,w,o,b)&&(u.push(A),e))return this.filteredrows=u,this.filterInitialized=!0,this}else for(A=0;A<x;A++)if(b=k[A],w(b[n],o,b)&&(u.push(A),e))return this.filteredrows=u,this.filterInitialized=!0,this;return this.filteredrows=u,this.filterInitialized=!0,this},y.prototype.where=function(t){var e,i=[];if("function"!=typeof t)throw new TypeError("Argument is not a stored view or a function");e=t;try{if(this.filterInitialized){for(var n=this.filteredrows.length;n--;)!0===e(this.collection.data[this.filteredrows[n]])&&i.push(this.filteredrows[n]);return this.filteredrows=i,this}for(var r=this.collection.data.length;r--;)!0===e(this.collection.data[r])&&i.push(r);return this.filteredrows=i,this.filterInitialized=!0,this}catch(t){throw t}},y.prototype.count=function(){return this.filterInitialized?this.filteredrows.length:this.collection.count()},y.prototype.data=function(t){var e,i,n,r,s=[],a=this.collection.data;if(t=t||{},t.removeMeta&&!t.forceClones&&(t.forceClones=!0,t.forceCloneMethod=t.forceCloneMethod||"shallow"),!this.collection.disableDeltaChangesApi&&this.collection.disableFreeze&&(t.forceClones=!0,t.forceCloneMethod="parse-stringify"),!this.filterInitialized){if(0===this.filteredrows.length){if(this.collection.cloneObjects||t.forceClones){for(i=a.length,r=t.forceCloneMethod||this.collection.cloneMethod,n=0;n<i;n++)e=d(a[n],r),t.removeMeta&&(delete e.$loki,delete e.meta),s.push(e);return s}return a.slice()}this.filterInitialized=!0}var o=this.filteredrows;if(i=o.length,this.collection.cloneObjects||t.forceClones)for(r=t.forceCloneMethod||this.collection.cloneMethod,n=0;n<i;n++)e=d(a[o[n]],r),t.removeMeta&&(delete e.$loki,delete e.meta),s.push(e);else for(n=0;n<i;n++)s.push(a[o[n]]);return s},y.prototype.update=function(t){if("function"!=typeof t)throw new TypeError("Argument is not a function");this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex());for(var e,i=this.filteredrows.length,n=this.collection.data,r=0;r<i;r++)this.disableFreeze&&!this.collection.cloneObjects&&this.collection.disableDeltaChangesApi?(t(n[this.filteredrows[r]]),this.collection.update(n[this.filteredrows[r]])):(e=d(n[this.filteredrows[r]],this.collection.cloneMethod),t(e),this.collection.update(e));return this},y.prototype.remove=function(){return this.filterInitialized||0!==this.filteredrows.length||(this.filteredrows=this.collection.prepareFullDocIndex()),this.collection.removeBatchByPositions(this.filteredrows),this.filteredrows=[],this},y.prototype.map=function(t,e){var i=this.data(e).map(t);return this.collection=new g("mappedData"),this.collection.insert(i),this.filteredrows=[],this.filterInitialized=!1,this},g.prototype=new u,g.prototype.contructor=g,g.prototype.lokiConsoleWrapper={log:function(){},warn:function(){},error:function(){}},g.prototype.addAutoUpdateObserver=function(t){},g.prototype.removeAutoUpdateObserver=function(t){},g.prototype.prepareFullDocIndex=function(){for(var t=this.data.length,e=new Array(t),i=0;i<t;i+=1)e[i]=i;return e},g.prototype.configureOptions=function(t){t=t||{},t.hasOwnProperty("adaptiveBinaryIndices")&&(this.adaptiveBinaryIndices=t.adaptiveBinaryIndices,this.adaptiveBinaryIndices&&this.ensureAllIndexes())},g.prototype.ensureIndex=function(t,e){if(void 0===e&&(e=!1),null===t||void 0===t)throw new Error("Attempting to set index without an associated property");if((!this.binaryIndices[t]||e||this.binaryIndices[t].dirty)&&(!0!==this.adaptiveBinaryIndices||!this.binaryIndices.hasOwnProperty(t)||e)){var i={name:t,dirty:!0,values:this.prepareFullDocIndex()};this.binaryIndices[t]=i;var n=function(t,e){var i,n,r=!!~t.indexOf(".")&&t.split(".");return function(s,a){if(r?(i=m.getIn(e[s],r,!0),n=m.getIn(e[a],r,!0)):(i=e[s][t],n=e[a][t]),i!==n){if(w.lt(i,n,!1))return-1;if(w.gt(i,n,!1))return 1}return 0}}(t,this.data);i.values.sort(n),i.dirty=!1,this.dirty=!0}},g.prototype.checkAllIndexes=function(t){var e,i=this.binaryIndices,n=[];for(e in i)I.call(i,e)&&(this.checkIndex(e,t)||n.push(e));return n},g.prototype.checkIndex=function(t,e){e=e||{},e.randomSamplingFactor&&!1!==e.randomSampling&&(e.randomSampling=!0),e.randomSamplingFactor=e.randomSamplingFactor||.1,(e.randomSamplingFactor<0||e.randomSamplingFactor>1)&&(e.randomSamplingFactor=.1);var i,n,r,s,a,o=!0;if(!this.binaryIndices.hasOwnProperty(t))throw new Error("called checkIndex on property without an index: "+t);if(this.adaptiveBinaryIndices||this.ensureIndex(t),a=this.binaryIndices[t].values,(s=a.length)!==this.data.length)return e.repair&&this.ensureIndex(t,!0),!1;if(0===s)return!0;var l=-1!==t.indexOf(".");if(1===s)o=0===a[0];else if(e.randomSampling){if(O.$lte(m.getIn(this.data[a[0]],t,l),m.getIn(this.data[a[1]],t,l))||(o=!1),O.$lte(m.getIn(this.data[a[s-2]],t,l),m.getIn(this.data[a[s-1]],t,l))||(o=!1),o)for(n=Math.floor((s-1)*e.randomSamplingFactor),i=0;i<n-1;i++)if(r=Math.floor(Math.random()*(s-1)),!O.$lte(m.getIn(this.data[a[r]],t,l),m.getIn(this.data[a[r+1]],t,l))){o=!1;break}}else for(i=0;i<s-1;i++)if(!O.$lte(m.getIn(this.data[a[i]],t,l),m.getIn(this.data[a[i+1]],t,l))){o=!1;break}return!o&&e.repair&&this.ensureIndex(t,!0),o},g.prototype.getBinaryIndexValues=function(t){var e,i=this.binaryIndices[t].values,n=[];for(e=0;e<i.length;e++)n.push(m.getIn(this.data[i[e]],t,!0));return n},g.prototype.getUniqueIndex=function(t,e){var i=this.constraints.unique[t];return!i&&e?this.ensureUniqueIndex(t):i},g.prototype.ensureUniqueIndex=function(t){var e=this.constraints.unique[t];return e||-1==this.uniqueNames.indexOf(t)&&this.uniqueNames.push(t),this.constraints.unique[t]=e=new b(t),this.data.forEach(function(t){e.set(t)}),e},g.prototype.ensureAllIndexes=function(t){var e,i=this.binaryIndices;for(e in i)I.call(i,e)&&this.ensureIndex(e,t)},g.prototype.flagBinaryIndexesDirty=function(){var t,e=this.binaryIndices;for(t in e)I.call(e,t)&&(e[t].dirty=!0)},g.prototype.flagBinaryIndexDirty=function(t){this.binaryIndices[t]&&(this.binaryIndices[t].dirty=!0)},g.prototype.count=function(t){return t?this.chain().find(t).filteredrows.length:this.data.length},g.prototype.ensureId=function(){if(!this.idIndex){var t=this.data,e=0,i=t.length,n=new Array(i);for(e;e<i;e++)n[e]=t[e].$loki;this.idIndex=n}},
g.prototype.findAndUpdate=function(t,e){"function"==typeof t?this.updateWhere(t,e):this.chain().find(t).update(e)},g.prototype.findAndRemove=function(t){this.chain().find(t).remove()},g.prototype.insert=function(t,e){if(!Array.isArray(t))return this.insertOne(t);var i,n=[],r=e&&!this.cloneObjects&&this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0;r&&(this.adaptiveBinaryIndices=!1);try{this.emit("pre-insert",t);for(var s=0,a=t.length;s<a;s++){if(!(i=this.insertOne(t[s],!0)))return;n.push(i)}}finally{r&&(this.ensureAllIndexes(),this.adaptiveBinaryIndices=!0)}return this.emit("insert",n),n=this.cloneObjects?d(n,this.cloneMethod):n,1===n.length?n[0]:n},g.prototype.insertOne=function(e,n){var r,s=null;if("object"!=typeof e?s=new TypeError("Document needs to be an object"):null===e&&(s=new TypeError("Object cannot be null")),null!==s)throw this.emit("error",s),s;var a=this.cloneObjects?d(e,this.cloneMethod):e;if(this.disableFreeze||(a=i(a)),this.disableMeta||(void 0===a.meta?a.meta={revision:0,created:0}:this.disableFreeze||(a.meta=i(a.meta))),n||this.emit("pre-insert",a),this.add(a))return this.disableFreeze||t(a),r=this.cloneObjects?d(a,this.cloneMethod):a,n||this.emit("insert",r),this.addAutoUpdateObserver(r),r},g.prototype.clear=function(t){var e=this;if(t=t||{},this.data=[],this.idIndex=null,this.cachedIndex=null,this.cachedBinaryIndex=null,this.cachedData=null,this.maxId=0,this.DynamicViews=[],this.dirty=!0,this.constraints={unique:{},exact:{}},!0===t.removeIndices)this.binaryIndices={},this.uniqueNames=[];else{Object.keys(this.binaryIndices).forEach(function(t){e.binaryIndices[t].dirty=!1,e.binaryIndices[t].values=[]})}},g.prototype.update=function(e){var i,n,r;if(Array.isArray(e)){r=e.length,(i=!this.cloneObjects&&this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0)&&(this.adaptiveBinaryIndices=!1);try{for(n=0;n<r;n+=1)this.update(e[n])}finally{i&&(this.ensureAllIndexes(),this.adaptiveBinaryIndices=!0)}}else{if(!I.call(e,"$loki"))throw new Error("Trying to update unsynced document. Please save the document first by using insert() or addMany()");try{this.startTransaction();var s,a,o,l=this.get(e.$loki,!0),h=this;if(!l)throw new Error("Trying to update a document not in collection.");s=l[0],o=l[1],a=this.cloneObjects||!this.disableDeltaChangesApi&&this.disableFreeze?d(e,this.cloneMethod):e,this.emit("pre-update",e),this.uniqueNames.forEach(function(t){h.getUniqueIndex(t,!0).update(s,a)}),this.data[o]=a,a!==e&&this.addAutoUpdateObserver(e);for(var c=0;c<this.DynamicViews.length;c++)this.DynamicViews[c].evaluateDocument(o,!1);var u;if(this.adaptiveBinaryIndices){var f=this.binaryIndices;for(u in f)this.adaptiveBinaryIndexUpdate(o,u)}else this.flagBinaryIndexesDirty();this.idIndex[o]=a.$loki,this.isIncremental&&this.dirtyIds.push(a.$loki),this.commit(),this.dirty=!0,this.disableFreeze||t(a);var p;return p=this.cloneObjects?d(a,this.cloneMethod):a,this.emit("update",p,s),p}catch(t){throw this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),t}}},g.prototype.add=function(t){if("object"!=typeof t)throw new TypeError("Object being added needs to be an object");if(void 0!==t.$loki)throw new Error("Document is already in collection, please use update()");try{this.startTransaction(),this.maxId++,isNaN(this.maxId)&&(this.maxId=this.data[this.data.length-1].$loki+1);var e=this.maxId;t.$loki=e,this.disableMeta||(t.meta.version=0);for(var i=0,n=this.uniqueNames.length;i<n;i++)this.getUniqueIndex(this.uniqueNames[i],!0).set(t);this.idIndex&&this.idIndex.push(e),this.isIncremental&&this.dirtyIds.push(e),this.data.push(t);var r=this.data.length-1,s=this.DynamicViews.length;for(i=0;i<s;i++)this.DynamicViews[i].evaluateDocument(r,!0);if(this.adaptiveBinaryIndices){var a=this.binaryIndices;for(var o in a)this.adaptiveBinaryIndexInsert(r,o)}else this.flagBinaryIndexesDirty();return this.commit(),this.dirty=!0,this.cloneObjects?d(t,this.cloneMethod):t}catch(t){throw this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),t}},g.prototype.updateWhere=function(t,e){var i,n=this.where(t),r=0;try{for(r;r<n.length;r++)i=e(n[r]),this.update(i)}catch(t){this.rollback(),this.lokiConsoleWrapper.error(t.message)}},g.prototype.removeWhere=function(t){var e;"function"==typeof t?(e=this.data.filter(t),this.remove(e)):this.chain().find(t).remove()},g.prototype.removeDataOnly=function(){this.remove(this.data.slice())},g.prototype.removeBatchByPositions=function(t){var e,i,n,r,s=t.length,a={},o=Object.keys(this.binaryIndices).length,l=Object.keys(this.constraints.unique).length,h=this.adaptiveBinaryIndices&&Object.keys(this.binaryIndices).length>0,c=this;try{for(this.startTransaction(),this.ensureId(),n=0;n<s;n++)a[this.idIndex[t[n]]]=!0;if((e=this.DynamicViews.length)>0||o>0||l>0){if(e>0)for(i=0;i<e;i++)this.DynamicViews[i].removeDocument(t);if(this.adaptiveBinaryIndices&&!h){var d,u=this.binaryIndices;for(d in u)this.adaptiveBinaryIndexRemove(t,d)}else this.flagBinaryIndexesDirty();l&&this.uniqueNames.forEach(function(e){var i=c.getUniqueIndex(e);if(i)for(n=0;n<s;n++)r=c.data[t[n]],null!==r[e]&&void 0!==r[e]&&i.remove(r[e])})}if(!this.disableChangesApi||this.events.delete.length>1)for(n=0;n<s;n++)this.emit("delete",this.data[t[n]]);if(this.data=this.data.filter(function(t){return!a[t.$loki]}),this.isIncremental)for(n=0;n<s;n++)this.dirtyIds.push(this.idIndex[t[n]]);this.idIndex=this.idIndex.filter(function(t){return!a[t]}),this.adaptiveBinaryIndices&&h&&(this.adaptiveBinaryIndices=!1,this.ensureAllIndexes(!0),this.adaptiveBinaryIndices=!0),this.commit(),this.dirty=!0}catch(t){return this.rollback(),h&&(this.adaptiveBinaryIndices=!0),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),null}},g.prototype.removeBatch=function(t){var e,i=t.length,n=this.data.length,r={},s=[];for(e=0;e<n;e++)r[this.data[e].$loki]=e;for(e=0;e<i;e++)"object"==typeof t[e]?s.push(r[t[e].$loki]):s.push(r[t[e]]);this.removeBatchByPositions(s)},g.prototype.remove=function(t){if("number"==typeof t&&(t=this.get(t)),"object"!=typeof t)throw new Error("Parameter is not an object");if(Array.isArray(t))return void this.removeBatch(t);if(!I.call(t,"$loki"))throw new Error("Object is not a document stored in the collection");try{this.startTransaction();var n=this.get(t.$loki,!0),r=n[1],s=this;this.uniqueNames.forEach(function(e){if(null!==t[e]&&void 0!==t[e]){var i=s.getUniqueIndex(e);i&&i.remove(t[e])}});for(var a=0;a<this.DynamicViews.length;a++)this.DynamicViews[a].removeDocument(r);if(this.adaptiveBinaryIndices){var o,l=this.binaryIndices;for(o in l)this.adaptiveBinaryIndexRemove(r,o)}else this.flagBinaryIndexesDirty();return this.data.splice(r,1),this.removeAutoUpdateObserver(t),this.idIndex.splice(r,1),this.isIncremental&&this.dirtyIds.push(t.$loki),this.commit(),this.dirty=!0,this.emit("delete",n[0]),this.disableFreeze||(t=i(t)),delete t.$loki,delete t.meta,this.disableFreeze||e(t),t}catch(t){return this.rollback(),this.lokiConsoleWrapper.error(t.message),this.emit("error",t),null}},g.prototype.get=function(t,e){this.idIndex||this.ensureId();var i=e||!1,n=this.idIndex,r=n.length-1,s=0,a=s+r>>1;if(t="number"==typeof t?t:parseInt(t,10),isNaN(t))throw new TypeError("Passed id is not an integer");for(;n[s]<n[r];)a=s+r>>1,n[a]<t?s=a+1:r=a;return r===s&&n[s]===t?i?[this.data[s],s]:this.data[s]:null},g.prototype.getBinaryIndexPosition=function(t,e){var i=m.getIn(this.data[t],e,!0),n=this.binaryIndices[e].values,r=this.calculateRange("$eq",e,i);if(0===r[0]&&-1===r[1])return null;for(var s=r[0],a=r[1],o=s;o<=a;o++)if(n[o]===t)return o;return null},g.prototype.adaptiveBinaryIndexInsert=function(t,e){var i=-1!==e.indexOf("."),n=this.binaryIndices[e].values,r=m.getIn(this.data[t],e,i);!0===this.serializableIndices&&r instanceof Date&&(this.data[t][e]=r.getTime(),r=m.getIn(this.data[t],e));var s=0===n.length?0:this.calculateRangeStart(e,r,!0,i);this.binaryIndices[e].values.splice(s,0,t)},g.prototype.adaptiveBinaryIndexUpdate=function(t,e){var i,n=this.binaryIndices[e].values,r=n.length;for(i=0;i<r&&n[i]!==t;i++);this.binaryIndices[e].values.splice(i,1),this.adaptiveBinaryIndexInsert(t,e)},g.prototype.adaptiveBinaryIndexRemove=function(t,e,i){var n,r,s,a,o,l,h,c=this.binaryIndices[e],d={};if(Array.isArray(t)){if(1!==(a=t.length)){for(s=0;s<a;s++)d[t[s]]=!0;if(c.values=c.values.filter(function(t){return!d[t]}),!0===i)return;var u=t.slice();for(u.sort(function(t,e){return t-e}),n=c.values.length,r=0;r<n;r++){for(o=c.values[r],l=0,s=0;s<a&&o>u[s];s++)l++;c.values[r]-=l}return}t=t[0]}if(null===(h=this.getBinaryIndexPosition(t,e)))return null;if(c.values.splice(h,1),!0!==i)for(n=c.values.length,r=0;r<n;r++)c.values[r]>t&&c.values[r]--},g.prototype.calculateRangeStart=function(t,e,i,n){var r=this.data,s=this.binaryIndices[t].values,a=0,o=s.length-1,l=0;if(0===s.length)return-1;for(m.getIn(r[s[a]],t,n),m.getIn(r[s[o]],t,n);a<o;)l=a+o>>1,w.lt(m.getIn(r[s[l]],t,n),e,!1)?a=l+1:o=l;var h=a;return w.aeq(e,m.getIn(r[s[h]],t,n))?h:w.lt(e,m.getIn(r[s[h]],t,n),!1)?i?h:h-1:i?h+1:h},g.prototype.calculateRangeEnd=function(t,e,i){var n=this.data,r=this.binaryIndices[t].values,s=0,a=r.length-1,o=0;if(0===r.length)return-1;for(m.getIn(n[r[s]],t,i),m.getIn(n[r[a]],t,i);s<a;)o=s+a>>1,w.lt(e,m.getIn(n[r[o]],t,i),!1)?a=o:s=o+1;var l=a;return w.aeq(e,m.getIn(n[r[l]],t,i))?l:w.gt(e,m.getIn(n[r[l]],t,i),!1)?l+1:w.aeq(e,m.getIn(n[r[l-1]],t,i))?l-1:l},g.prototype.calculateRange=function(t,e,i){var n,r,s,a=this.data,o=this.binaryIndices[e].values,l=o.length-1;if(0===a.length)return[0,-1];var h=-1!==e.indexOf("."),c=m.getIn(a[o[0]],e,h),d=m.getIn(a[o[l]],e,h);switch(t){case"$eq":case"$aeq":case"$dteq":if(w.lt(i,c,!1)||w.gt(i,d,!1))return[0,-1];break;case"$gt":if(w.gt(i,d,!0))return[0,-1];if(w.gt(c,i,!1))return[0,l];break;case"$gte":if(w.gt(i,d,!1))return[0,-1];if(w.gt(c,i,!0))return[0,l];break;case"$lt":if(w.lt(i,c,!0))return[0,-1];if(w.lt(d,i,!1))return[0,l];break;case"$lte":if(w.lt(i,c,!1))return[0,-1];if(w.lt(d,i,!0))return[0,l];break;case"$between":return w.gt(i[0],d,!1)?[0,-1]:w.lt(i[1],c,!1)?[0,-1]:(n=this.calculateRangeStart(e,i[0],!1,h),s=this.calculateRangeEnd(e,i[1],h),n<0&&n++,s>l&&s--,w.gt(m.getIn(a[o[n]],e,h),i[0],!0)||n++,w.lt(m.getIn(a[o[s]],e,h),i[1],!0)||s--,s<n?[0,-1]:[n,s]);case"$in":for(var u=[],f=[],p=0,y=i.length;p<y;p++)for(var v=this.calculateRange("$eq",e,i[p]),g=v[0];g<=v[1];g++)void 0===u[g]&&(u[g]=!0,f.push(g));return f}switch(t){case"$eq":case"$aeq":case"$dteq":case"$gte":case"$lt":n=this.calculateRangeStart(e,i,!1,h),r=m.getIn(a[o[n]],e,h)}switch(t){case"$eq":case"$aeq":case"$dteq":case"$lte":case"$gt":s=this.calculateRangeEnd(e,i,h),m.getIn(a[o[s]],e,h)}switch(t){case"$eq":case"$aeq":case"$dteq":return w.aeq(r,i)?[n,s]:[0,-1];case"$gt":return w.aeq(m.getIn(a[o[s]],e,h),i)?[s+1,l]:[s,l];case"$gte":return w.aeq(m.getIn(a[o[n]],e,h),i)?[n,l]:[n+1,l];case"$lt":return w.aeq(m.getIn(a[o[n]],e,h),i)?[0,n-1]:[0,n];case"$lte":return w.aeq(m.getIn(a[o[s]],e,h),i)?[0,s]:[0,s-1];default:return[0,a.length-1]}},g.prototype.by=function(t,e){var i;if(void 0===e)return i=this,function(e){return i.by(t,e)};var n=this.getUniqueIndex(t,!0).get(e);return this.cloneObjects?d(n,this.cloneMethod):n},g.prototype.findOne=function(t){t=t||{};var e=this.chain().find(t,!0).data();return Array.isArray(e)&&0===e.length?null:this.cloneObjects?d(e[0],this.cloneMethod):e[0]},g.prototype.chain=function(t,e){var i=new y(this);return void 0===t?i:i.transform(t,e)},g.prototype.find=function(t){return this.chain().find(t).data()},g.prototype.findOneUnindexed=function(t,e){for(var i=this.data.length;i--;)if(m.getIn(this.data[i],t,!0)===e)return this.data[i];return null},g.prototype.startTransaction=function(){},g.prototype.commit=function(){},g.prototype.rollback=function(){},g.prototype.where=function(t){return this.chain().where(t).data()},b.prototype.keyMap={},b.prototype.lokiMap={},b.prototype.set=function(t){var e=t[this.field];if(null!==e&&void 0!==e){if(this.keyMap[e])throw new Error("Duplicate key for property "+this.field+": "+e);this.keyMap[e]=t,this.lokiMap[t.$loki]=e}},b.prototype.get=function(t){return this.keyMap[t]},b.prototype.byId=function(t){return this.keyMap[this.lokiMap[t]]},b.prototype.update=function(t,e){if(this.lokiMap[t.$loki]!==e[this.field]){var i=this.lokiMap[t.$loki];this.set(e),this.keyMap[i]=void 0}else this.keyMap[t[this.field]]=e},b.prototype.remove=function(t){var e=this.keyMap[t];if(null===e||void 0===e)throw new Error("Key is not in unique index: "+this.field);this.keyMap[t]=void 0,this.lokiMap[e.$loki]=void 0},b.prototype.clear=function(){this.keyMap=Object.create(null),this.lokiMap=Object.create(null)},f.deepFreeze=t,f.freeze=e,f.unFreeze=i,f.LokiOps=O,f.Collection=g,f.Resultset=y,f.LokiMemoryAdapter=p,f.aeq=n,f.lt=r,f.gt=s,f.Comparators=w,f}()});
{
"name": "@nozbe/lokijs",
"version": "1.5.12-wmelon4",
"version": "1.5.12-wmelon5",
"description": "Nozbe's fork of LokiJS, optimized for WatermelonDB",

@@ -5,0 +5,0 @@ "homepage": "https://techfort.github.io/LokiJS/",

@@ -56,3 +56,4 @@ (function(root, factory) {

this.chunkSize = 100;
this.megachunkCount = this.options.megachunkCount || 20;
this.megachunkCount = this.options.megachunkCount || 24;
this.lazyCollections = this.options.lazyCollections || [];
this.idb = null; // will be lazily loaded on first operation that needs it

@@ -435,3 +436,3 @@ this._prevLokiVersionId = null;

// populate collections with data
populateLoki(loki, chunks.chunkMap);
populateLoki(loki, chunks.chunkMap, that.options.deserializeChunk, that.lazyCollections);
chunks = null; // gc

@@ -461,34 +462,26 @@

chunks.forEach(function(object) {
var key = object.key;
var value = object.value;
if (key === "loki") {
chunks.forEach(function(chunk) {
var type = chunk.type;
var value = chunk.value;
var name = chunk.collectionName;
if (type === "loki") {
loki = value;
return;
} else if (key.includes(".")) {
var keySegments = key.split(".");
if (keySegments.length === 3 && keySegments[1] === "chunk") {
var colName = keySegments[0];
if (chunkMap[colName]) {
chunkMap[colName].dataChunks.push(value);
} else {
chunkMap[colName] = {
metadata: null,
dataChunks: [value],
};
}
return;
} else if (keySegments.length === 2 && keySegments[1] === "metadata") {
var name = keySegments[0];
if (chunkMap[name]) {
chunkMap[name].metadata = value;
} else {
chunkMap[name] = { metadata: value, dataChunks: [] };
}
return;
} else if (type === "data") {
if (chunkMap[name]) {
chunkMap[name].dataChunks.push(value);
} else {
chunkMap[name] = {
metadata: null,
dataChunks: [value],
};
}
} else if (type === "metadata") {
if (chunkMap[name]) {
chunkMap[name].metadata = value;
} else {
chunkMap[name] = { metadata: value, dataChunks: [] };
}
} else {
throw new Error("unreachable");
}
console.error("Unknown chunk " + key);
throw new Error("Corrupted database - unknown chunk found");
});

@@ -503,21 +496,34 @@

function populateLoki(loki, chunkMap) {
function populateLoki(loki, chunkMap, deserializeChunk, lazyCollections) {
loki.collections.forEach(function populateCollection(collectionStub, i) {
var chunkCollection = chunkMap[collectionStub.name];
var name = collectionStub.name;
var chunkCollection = chunkMap[name];
if (chunkCollection) {
if (!chunkCollection.metadata) {
throw new Error("Corrupted database - missing metadata chunk for " + collectionStub.name);
throw new Error("Corrupted database - missing metadata chunk for " + name);
}
var collection = chunkCollection.metadata;
chunkCollection.metadata = null;
loki.collections[i] = collection;
var dataChunks = chunkCollection.dataChunks;
dataChunks.forEach(function populateChunk(chunk, i) {
chunk.forEach(function(doc) {
collection.data.push(doc);
var isLazy = lazyCollections.includes(name);
var lokiDeserializeCollectionChunks = function () {
DEBUG && isLazy && console.log("lazy loading " + name);
var data = [];
var dataChunks = chunkCollection.dataChunks;
dataChunks.forEach(function populateChunk(chunk, i) {
if (isLazy) {
chunk = JSON.parse(chunk);
if (deserializeChunk) {
chunk = deserializeChunk(name, chunk);
}
}
chunk.forEach(function(doc) {
data.push(doc);
});
dataChunks[i] = null;
});
dataChunks[i] = null;
});
return data;
};
collection.getData = lokiDeserializeCollectionChunks;
}

@@ -536,20 +542,4 @@ });

var openRequest = indexedDB.open(dbname, 1);
openRequest.onupgradeneeded = function(e) {
var db = e.target.result;
DEBUG && console.log('onupgradeneeded, old version: ' + e.oldVersion);
if (e.oldVersion < 1) {
// Version 1 - Initial - Create database
db.createObjectStore('LokiIncrementalData', { keyPath: "key" });
} else {
// Unknown version
throw new Error("Invalid old version " + e.oldVersion + " for IndexedDB upgrade");
}
};
openRequest.onsuccess = function(e) {
function onDidOpen(db) {
that.idbInitInProgress = false;
var db = e.target.result;
that.idb = db;

@@ -587,4 +577,32 @@

onSuccess();
}
if (this.options.preloads && this.options.preloads.idb) {
DEBUG && console.log('using preloaded idb');
onDidOpen(this.options.preloads.idb);
this.options.preloads.idb = null;
return;
}
var openRequest = indexedDB.open(dbname, 1);
openRequest.onupgradeneeded = function(e) {
var db = e.target.result;
DEBUG && console.log('onupgradeneeded, old version: ' + e.oldVersion);
if (e.oldVersion < 1) {
// Version 1 - Initial - Create database
db.createObjectStore('LokiIncrementalData', { keyPath: "key" });
} else {
// Unknown version
throw new Error("Invalid old version " + e.oldVersion + " for IndexedDB upgrade");
}
};
openRequest.onsuccess = function(e) {
that.idbInitInProgress = false;
var db = e.target.result;
onDidOpen(db);
};
openRequest.onblocked = function(e) {

@@ -615,2 +633,3 @@ console.error("IndexedDB open is blocked", e);

var deserializeChunk = this.options.deserializeChunk;
var lazyCollections = this.lazyCollections;

@@ -632,3 +651,3 @@ // If there are a lot of chunks (>100), don't request them all in one go, but in multiple

megachunk.forEach(function (chunk, i) {
parseChunk(chunk, deserializeChunk);
parseChunk(chunk, deserializeChunk, lazyCollections);
allChunks.push(chunk);

@@ -647,7 +666,9 @@ megachunk[i] = null; // gc

// back. This further improves concurrency.
function requestMegachunk(index) {
var megachunkWaves = 2;
var megachunksPerWave = megachunkCount / megachunkWaves;
function requestMegachunk(index, wave) {
var keyRange = keyRanges[index];
idbReq(store.getAll(keyRange), function(e) {
if (index < megachunkCount / 2) {
requestMegachunk(index + megachunkCount / 2);
if (wave < megachunkWaves) {
requestMegachunk(index + megachunksPerWave, wave + 1);
}

@@ -661,4 +682,4 @@

for (var i = 0; i < megachunkCount / 2; i += 1) {
requestMegachunk(i);
for (var i = 0; i < megachunksPerWave; i += 1) {
requestMegachunk(i, 1);
}

@@ -671,3 +692,3 @@ }

allChunks.forEach(function (chunk) {
parseChunk(chunk, deserializeChunk);
parseChunk(chunk, deserializeChunk, lazyCollections);
});

@@ -681,4 +702,4 @@ callback(allChunks);

function getAllKeys() {
idbReq(store.getAllKeys(), function(e) {
var keys = e.target.result.sort();
function onDidGetKeys(keys) {
keys.sort();
if (keys.length > 100) {

@@ -689,6 +710,16 @@ getMegachunks(keys);

}
}, function(e) {
callback(e);
});
}
if (that.options.preloads && that.options.preloads.keys) {
DEBUG && console.log('using preloaded keys');
onDidGetKeys(that.options.preloads.keys);
that.options.preloads.keys = null;
} else {
idbReq(store.getAllKeys(), function(e) {
onDidGetKeys(e.target.result);
}, function(e) {
callback(e);
});
}
if (that.options.onFetchStart) {

@@ -702,13 +733,40 @@ that.options.onFetchStart();

function parseChunk(chunk, deserializeChunk) {
chunk.value = JSON.parse(chunk.value);
if (deserializeChunk) {
var segments = chunk.key.split('.');
if (segments.length === 3 && segments[1] === 'chunk') {
var collectionName = segments[0];
chunk.value = deserializeChunk(collectionName, chunk.value);
function classifyChunk(chunk) {
var key = chunk.key;
if (key === 'loki') {
chunk.type = 'loki';
return;
} else if (key.includes('.')) {
var keySegments = key.split(".");
if (keySegments.length === 3 && keySegments[1] === "chunk") {
chunk.type = 'data';
chunk.collectionName = keySegments[0];
chunk.index = parseInt(keySegments[2], 10);
return;
} else if (keySegments.length === 2 && keySegments[1] === "metadata") {
chunk.type = 'metadata';
chunk.collectionName = keySegments[0];
return;
}
}
console.error("Unknown chunk " + key);
throw new Error("Corrupted database - unknown chunk found");
}
function parseChunk(chunk, deserializeChunk, lazyCollections) {
classifyChunk(chunk);
var isData = chunk.type === 'data';
var isLazy = lazyCollections.includes(chunk.collectionName);
if (!(isData && isLazy)) {
chunk.value = JSON.parse(chunk.value);
}
if (deserializeChunk && isData && !isLazy) {
chunk.value = deserializeChunk(chunk.collectionName, chunk.value);
}
}
/**

@@ -775,14 +833,2 @@ * Deletes a database from IndexedDB

function _getSortKey(object) {
var key = object.key;
if (key.includes(".")) {
var segments = key.split(".");
if (segments.length === 3 && segments[1] === "chunk") {
return parseInt(segments[2], 10);
}
}
return -1; // consistent type must be returned
}
function sortChunksInPlace(chunks) {

@@ -792,7 +838,3 @@ // sort chunks in place to load data in the right order (ascending loki ids)

chunks.sort(function(a, b) {
var aKey = _getSortKey(a),
bKey = _getSortKey(b);
if (aKey < bKey) return -1;
if (aKey > bKey) return 1;
return 0;
return (a.index || 0) - (b.index || 0);
});

@@ -799,0 +841,0 @@ }

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

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