!function(t){if("function"==typeofbootstrap)bootstrap("nedb",t);elseif("object"==typeofexports)module.exports=t();elseif("function"==typeofdefine&&define.amd)define(t);elseif("undefined"!=typeofses){if(!ses.ok())return;ses.makeNedb=t}else"undefined"!=typeofwindow?window.Nedb=t():global.Nedb=t()}(function(){vart;returnfunction(t,e,n){functionr(n,o){if(!e[n]){if(!t[n]){vara="function"==typeofrequire&&require;if(!o&&a)returna(n,!0);if(i)returni(n,!0);thrownewError("Cannot find module '"+n+"'")}varu=e[n]={exports:{}};t[n][0].call(u.exports,function(e){vari=t[n][1][e];returnr(i?i:e)},u,u.exports)}returne[n].exports}for(vari="function"==typeofrequire&&require,o=0;o<n.length;o++)r(n[o]);returnr}({1:[function(t,e,n){functionr(t,e){if(t.indexOf)returnt.indexOf(e);for(varn=0;n<t.length;n++)if(e===t[n])returnn;return-1}vari=t("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});varo=n.EventEmitter=i.EventEmitter,a="function"==typeofArray.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},u=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||a(this._events.error)&&!this._events.error.length))throwarguments[1]instanceofError?arguments[1]:newError("Uncaught, unspecified 'error' event.");if(!this._events)return!1;vare=this._events[t];if(!e)return!1;if("function"==typeofe){switch(arguments.length){case1:e.call(this);break;case2:e.call(this,arguments[1]);break;case3:e.call(this,arguments[1],arguments[2]);break;default:varn=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(a(e)){for(varn=Array.prototype.slice.call(arguments,1),r=e.slice(),i=0,o=r.length;o>i;i++)r[i].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeofe)thrownewError("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(a(this._events[t])){if(!this._events[t].warned){varn;n=void0!==this._events.maxListeners?this._events.maxListeners:u,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}elsethis._events[t]=[this._events[t],e];elsethis._events[t]=e;returnthis},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){varn=this;returnn.on(t,functionr(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeofe)thrownewError("removeListener only takes instances of Function");if(!this._events||!this._events[t])returnthis;varn=this._events[t];if(a(n)){vari=r(n,e);if(0>i)returnthis;n.splice(i,1),0==n.length&&deletethis._events[t]}elsethis._events[t]===e&&deletethis._events[t];returnthis},o.prototype.removeAllListeners=function(t){return0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},o.prototype.listeners=function(t){returnthis._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]},o.listenerCount=function(t,e){varn;returnn=t._events&&t._events[e]?"function"==typeoft._events[e]?1:t._events[e].length:0}},{__browserify_process:4}],2:[function(t,e,n){functionr(t,e){for(varn=[],r=0;r<t.length;r++)e(t[r],r,t)&&n.push(t[r]);returnn}functioni(t,e){for(varn=0,r=t.length;r>=0;r--){vari=t[r];"."==i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");returnt}varo=t("__browserify_process"),a=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(vart="",e=!1,n=arguments.length;n>=-1&&!e;n--){vara=n>=0?arguments[n]:o.cwd();"string"==typeofa&&a&&(t=a+"/"+t,e="/"===a.charAt(0))}returnt=i(r(t.split("/"),function(t
n.ensureDirectoryExists=function(t,e){varn=e||function(){};i.mkdirp(t,function(t){returnn(t)})},n.ensureFileDoesntExist=function(t,e){i.exists(t,function(n){returnn?(i.unlink(t,function(t){returne(t)}),void0):e(null)})},n.getNWAppFilename=function(t,e){varn;switch(r.platform){case"win32":case"win64":if(n=r.env.LOCALAPPDATA||r.env.APPDATA,!n)throw"Couldn't find the base application data folder";n=o.join(n,t);break;case"darwin":if(n=r.env.HOME,!n)throw"Couldn't find the base application data directory";n=o.join(n,"Library","Application Support",t);break;case"linux":if(n=r.env.HOME,!n)throw"Couldn't find the base application data directory";n=o.join(n,".config",t);break;default:throw"Can't use the Node Webkit relative path for platform "+r.platform}returno.join(n,"nedb-data",e)},n.prototype.persistCachedDatabase=function(t){vare=t||function(){},r="",o=this;returnthis.inMemoryOnly?e(null):(this.db.getAllData().forEach(function(t){r+=o.afterSerialization(a.serialize(t))+"\n"}),Object.keys(this.db.indexes).forEach(function(t){"_id"!=t&&(r+=o.afterSerialization(a.serialize({$$indexCreated:{fieldName:t,unique:o.db.indexes[t].unique,sparse:o.db.indexes[t].sparse}}))+"\n")}),u.waterfall([u.apply(n.ensureFileDoesntExist,o.tempFilename),u.apply(n.ensureFileDoesntExist,o.oldFilename),function(t){i.exists(o.filename,function(e){returne?(i.rename(o.filename,o.oldFilename,function(e){returnt(e)}),void0):t()})},function(t){i.writeFile(o.tempFilename,r,function(e){returnt(e)})},function(t){i.rename(o.tempFilename,o.filename,function(e){returnt(e)})},u.apply(n.ensureFileDoesntExist,o.oldFilename)],function(t){returnt?e(t):e(null)}),void0)},n.prototype.compactDatafile=function(){this.db.executor.push({"this":this,fn:this.persistCachedDatabase,arguments:[]})},n.prototype.setAutocompactionInterval=function(t){vare=this,n=5e3,r=Math.max(t||0,n);this.stopAutocompaction(),this.autocompactionIntervalId=setInterval(function(){e.compactDatafile()},r)},n.prototype.stopAutocompaction=function(){this.autocompactionIntervalId&&clearInterval(this.autocompactionIntervalId)},n.prototype.persistNewState=function(t,e){varn=this,r="",o=e||function(){};returnn.inMemoryOnly?o(null):(t.forEach(function(t){r+=n.afterSerialization(a.serialize(t))+"\n"}),0===r.length?o(null):(i.appendFile(n.filename,r,"utf8",function(t){returno(t)}),void0))},n.prototype.treatRawData=function(t){vare,n=t.split("\n"),r={},i=[],o={},u=-1;for(e=0;e<n.length;e+=1){vars;try{s=a.deserialize(this.beforeDeserialization(n[e])),s._id?s.$$deleted===!0?deleter[s._id]:r[s._id]=s:s.$$indexCreated&&void0!=s.$$indexCreated.fieldName?o[s.$$indexCreated.fieldName]=s.$$indexCreated:"string"==typeofs.$$indexRemoved&&deleteo[s.$$indexRemoved]}catch(c){u+=1}}if(n.length>0&&u/n.length>this.corruptAlertThreshold)throw"More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss";returnObject.keys(r).forEach(function(t){i.push(r[t])}),{data:i,indexes:o}},n.prototype.ensureDatafileIntegrity=function(t){vare=this;i.exists(e.filename,function(n){returnn?t(null):(i.exists(e.oldFilename,function(n){returnn?(i.rename(e.oldFilename,e.filename,function(e){returnt(e)}),void0):i.writeFile(e.filename,"","utf8",function(e){t(e)})}),void0)})},n.prototype.loadDatabase=function(t){vare=t||function(){},r=this;returnr.db.resetIndexes(),r.inMemoryOnly?e(null):(u.waterfall([function(t){n.ensureDirectoryExists(o.dirname(r.filename),function(){r.ensureDatafileIntegrity(function(){i.readFile(r.filename,"utf8",function(e,n){if(e)returnt(e);try{vari=r.treatRawData(n)}catch(o){returnt(o)}Object.keys(i.indexes).forEach(function(t){r.db.indexes[t]=newc(i.indexes[t])});try{r.db.resetIndexes(i.data)}catch(o){returnr.db.resetIndexes(),t(o)}r.db.persistence.persistCachedDatabase(t)})})})}],function(t){returnt?e(t):(r.db.executor.processBuffer(),e(null))}),void0)},e.exports=n},{"./customUtils":6,"./indexes":9,"./model":10,"./storage":12,__browserify_process:4,async:13,path:2}],12:[function(t,e){functionn(t,e)