text: function def(a,b,c){var d="undefined"!=typeof define,e="undefined"!=typeof exports;if(!c&&b instanceof Function&&(c=b,b=[]),d)define.amd?define(c):define(a,b,c);else if(e)exports=c(require,exports,f);else{var f={exports:{}};def.cache[a]=this[a]=f.exports=c(function(a){return def.cache.hasOwnProperty(a)?def.cache[a]:null},f.exports,f)}}!function(a,b){function c(){return b.createElement("script")}if(a&&b){var d=b.getElementsByTagName("script")[0],e=d.parentNode;if(!a.JSON){var f=c();f.src="//cdn.staticfile.org/json2/20121008/json2.min.js",e.insertBefore(f,d)}if(!Function.prototype.bind||!Array.isArray){var g=c();g.src="//cdn.staticfile.org/es5-shim/2.1.0/es5-shim.min.js",e.insertBefore(g,d);var h=c();h.src="//cdn.staticfile.org/es5-shim/2.1.0/es5-sham.min.js",e.insertBefore(h,d)}Object.create||(Object.create=function(){function a(){}return function(b,c){a.prototype={};for(var d in b)a.prototype[d]=b[d];for(var d in c)a.prototype[d]=c[d];return new a}}())}}("undefined"!=typeof window?window:this,"undefined"!=typeof document?document:null),def.cache={},def("min.utils",[],function(){var a={noop:function(){return!1},inherits:function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},extend:function(){for(var a=arguments[0],b=[].slice.call(arguments,1),c=0,d=b.length;d>c;c++)for(var e in b[c])a[e]=b[c][e];return a},isNumber:function(a){return"[object Number]"==toString.call(a)},isUndefined:function(a){return void 0===a},isObject:function(a){return a===Object(a)},arrayUnique:function(b){for(var c={},d=[],e=0,f=b.length;f>e;++e)(!c.hasOwnProperty(b[e])||a.isObject(b[e]))&&(d.push(b[e]),c[b[e]]=1);return d},arrayInter:function(b){var c=[].slice.call(arguments,1);return a.arrayUnique(b).filter(function(a){for(var b=!0,d=0;d<c.length;d++)!function(d){var e=c[d];e.indexOf(a)<0&&(b=!1)}(d);return b})},arrayDiff:function(a){var b=[].slice.call(arguments,1);return a.filter(function(a){for(var c=!0,d=0;d<b.length;d++)!function(d){var e=b[d];e.indexOf(a)>=0&&(c=!1)}(d);return c})}};return a}),def("min.deps.events",["min.utils"],function(a){function b(){this._events=this._events||{},this._maxListeners=this._maxListeners||f}function c(a){this.results=null,this.errors=null,this.ended=!1,"function"==typeof a&&this.then(a)}function d(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b}if("undefined"!=typeof define&&define.amd)var e=arguments[0];else var e=a("min.utils");var f=10;return b.prototype.setMaxListeners=function(a){if("number"!=typeof a||0>a)throw TypeError("n must be a positive number");this._maxListeners=a},b.prototype.emit=function(a){var b,c,d,e,f,g;if(this._events||(this._events={}),"error"===a&&(!this._events.error||"object"==typeof this._events.error&&!this._events.error.length)){if(b=arguments[1],!this.domain)throw b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');return b||(b=new TypeError('Uncaught, unspecified "error" event.')),!1}if(c=this._events[a],"undefined"==typeof c)return!1;if("function"==typeof c)switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,e=new Array(d-1),f=1;d>f;f++)e[f-1]=arguments[f];c.apply(this,e)}else if("object"==typeof c){for(d=arguments.length,e=new Array(d-1),f=1;d>f;f++)e[f-1]=arguments[f];for(g=c.slice(),d=g.length,f=0;d>f;f++)g[f].apply(this,e)}return!0},b.prototype.addListener=function(a,b){var c;if("function"!=typeof b)throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,"function"==typeof b.listener?b.listener:b),this._events[a]?"object"==typeof this._events[a]?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,"object"!=typeof this._events[a]||this._events[a].warned||(c=this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())),this},b.prototype.on=b.prototype.addListener,b.prototype.once=function(a,b){function c(){this.removeListener(a,c),b.apply(this,arguments)}if("function"!=typeof b)throw TypeError("listener must be a function");return c.listener=b,this.on(a,c),this},b.prototype.removeListener=function(a,b){var c,d,e,f;if("function"!=typeof b)throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],e=c.length,d=-1,c===b||"function"==typeof c.listener&&c.listener===b)this._events[a]=void 0,this._events.removeListener&&this.emit("removeListener",a,b);else if("object"==typeof c){for(f=e;f-->0;)if(c[f]===b||c[f].listener&&c[f].listener===b){d=f;break}if(0>d)return this;1===c.length?(c.length=0,this._events[a]=void 0):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},b.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&(this._events[a]=void 0),this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],"function"==typeof c)this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return this._events[a]=void 0,this},b.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?"function"==typeof this._events[a]?[this._events[a]]:this._events[a].slice():[]},b.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?"function"==typeof a._events[b]?1:a._events[b].length:0},e.inherits(c,b),c.prototype.resolve=function(){var a=d(arguments);return this.emit("fulfill",a),this.ended=!0,this.results=a,this},c.prototype.reject=function(){var a=d(arguments);return this.emit("reject",a),this.ended=!0,this.errors=a,this},c.prototype.then=function(a,b){var d=new c,f=this;a=a||e.noop,b=b||e.noop;var g=function(a){a&&"function"==typeof a.then?a.then(function(){d.resolve.apply(d,arguments)},function(a){d.reject(a)}):a instanceof Error&&d.reject(a)};return f.ended&&(f.results||f.errors)?(f.results&&g(a.apply(null,f.results)),f.errors&&(b.apply(null,f.errors),g.apply(null,f.errors))):f.once("fulfill",function(b){return g(a.apply(null,b))}).once("reject",function(a){return b.call(null,a),g(a)}),d},c.prototype.fail=function(a){var b=this;return b.ended&&null!==b.errors?a.apply(b,b.errors):b.once("reject",function(c){a.apply(b,c),b.ended=!1}),b},{EventEmitter:b,Promise:c}}),def("min.mix",["min.utils","min.deps.events"],function(a){if("undefined"!=typeof define&&define.amd)var b=arguments[0],c=arguments[1];else var b=a("min.utils"),c=a("min.deps.events");var d=c.Promise,e={},f=null;return e.set=function(a,c,e){var g=this,h=new d(function(){f&&clearTimeout(f),f=setTimeout(g.save.bind(g),5e3)}),i=this.store;e=e||b.noop;var j="min-"+a;if(i.async){var k=function(){var b=JSON.stringify(c);i.set(j,b,function(b){return b?(h.reject(b),e(b)):(g._keys[a]=0,h.resolve(a,c),e(null,a,c),void 0)})};i.ready?k():i.on("ready",k)}else try{var l=JSON.stringify(c);i.set(j,l),g._keys[a]=0,h.resolve(a,c),e(null,a,c)}catch(m){h.reject(m),e(m)}return this.emit("set",a,c),h},e.setnx=function(a,c,e){var f=new d,g=this;return e=e||b.noop,g.exists(a,function(b,d){return b&&(e(b),f.reject(b)),d?f.reject(new Error("The key is exists.")):(g.set(a,c,e).then(function(a,b){e(null,a,b),f.resolve(a,b)}).fail(function(a){e(a),f.reject(a)}),void 0)}),f},e.setex=function(a,c,e,f){function g(){i.del(a,b.noop)}var h=new d,i=this;return f=f||b.noop,i.set(a,e,function(a,b){setTimeout(g,1e3*c),f(a,b)}).then(function(a,b){setTimeout(g,1e3*c),h.resolve(a,b),f(null,a,b)}).fail(function(a){h.reject(a),f(a)}),h},e.psetex=function(a,c,e,f){function g(){i.del(a,b.noop)}var h=new d,i=this;return f=f||b.noop,i.set(a,e,function(a,b){setTimeout(g,c),f(a,b)}).then(function(){setTimeout(g,c),h.resolve.apply(h,arguments)}).fail(h.reject.bind(h)),h},e.mset=function(a,c){function e(b,c){delete i[c],h.set(b,a[b]).then(function(){k.push(arguments),j++,i[j]?e(i[j],j):f()}).fail(function(a){return l.push(a),j++,i[j]?e(i[j],j):f()})}function f(){l.length?(c(l),g.reject(l)):(c(null,k),g.resolve(k))}var g=new d,h=this,i=Object.keys(a),j=0,k=[],l=[];return c=c||b.noop,e(i[j],j),g},e.msetnx=function(a,c){function e(b,c){delete i[c],h.setnx(b,a[b]).then(function(){k.push(arguments),j++,i[j]?e(i[j],j):f()}).fail(function(a){l.push(a),f()})}function f(){return l.length?(c(l),g.reject(l)):(c(null,k),g.resolve(k),void 0)}var g=new d,h=this,i=Object.keys(a),j=0,k=[],l=[];return c=c||b.noop,e(i[j],j),g},e.append=function(a,c,e){var f=this,g=new d;return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new d;return c.resolve(""),c}).then(function(b){return f.set(a,b+c)}).then(function(a){return f.strlen(a)}).then(function(a){g.resolve(a),e(null,a)}).fail(function(a){g.reject(a),e(a)}),g},e.get=function(a,c){var e=this,f=new d(function(b){e.emit("get",a,b)}),g=this.store;c=c||b.noop;var h="min-"+a;if(g.async){var i=function(){g.get(h,function(a,b){if(a){var d=new Error("no such key");return f.reject(d),c(d)}if(b){var e=JSON.parse(b);f.resolve(e),c(null,e)}else{var a=new Error("no such key");f.resolve(a),c(a)}})};g.ready?i():g.on("ready",i)}else try{var j=this.store.get(h);if(j){var k=JSON.parse(j);f.resolve(k),c(null,k)}else{var l=new Error("no such key");f.reject(l),c(l)}}catch(l){f.reject(l),c(l)}return f},e.getrange=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("getrange",a,c,e,b)});f=f||b.noop;var i=e-c+1;return g.get(a).then(function(a){var b=a.substr(c,i);h.resolve(b),f(null,b)}).fail(function(a){h.reject(a),f(a)}),h},e.mget=function(a,c){function e(b,c){delete a[c],h.get(b,function(b,c){return b?(k.push(b),j.push(null),i++,a[i]?e(a[i],i):f()):(j.push(c),i++,a[i]?e(a[i],i):f(),void 0)})}function f(){k.length?g.reject(k):g.resolve(j)}var g=new d,h=this,i=0,j=[],k=[];return c=c||b.noop,e(a[i],i),g},e.getset=function(a,c,e){var f=this,g=new d(function(b){f.emit("getset",a,c,b)});"undefined"==typeof e&&(e=b.noop);var h=null;return f.get(a).then(function(b){return h=b,f.set(a,c)}).then(function(){g.resolve(h),e(null,h)}).fail(function(a){g.reject(a),e(a)}),g},e.strlen=function(a,c){var e=this,f=new d;return c=c||b.noop,e.get(a).then(function(a){if("string"==typeof a){var b=a.length;f.resolve(b),c(null,b)}else{var d=new TypeError;f.reject(d),c(d)}}).fail(function(a){f.reject(a),c(a)}),f},e.incr=function(a,c){var e=this,f=new d(function(b){e.emit("incr",a,b)});return c=c||b.noop,e.exists(a).then(function(b){if(b)return e.get(a);var c=new d;return c.resolve(0),c}).then(function(b){return isNaN(parseInt(b))?(f.reject("value wrong"),c("value wrong")):(b=parseInt(b),e.set(a,++b))}).then(function(a,b){f.resolve(b),c(null,b)}).fail(function(a){f.reject(a),c(a)}),f},e.incrby=function(a,c,e){var f=this,g=new d(function(b){f.emit("incrby",a,b)});return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new d;return c.resolve(0),c}).then(function(b){return isNaN(parseFloat(b))?(g.reject("value wrong"),e("value wrong")):(b=parseFloat(b),f.set(a,b+c))}).then(function(a,b){g.resolve(b),e(null,b)}).fail(function(a){g.reject(a),e(a)}),g},e.incrbyfloat=e.incrby,e.decr=function(a,c){var e=this,f=new d(function(b){e.emit("decr",a,b)});return c=c||b.noop,e.exists(a).then(function(b){if(b)return e.get(a);var c=new d;return c.resolve(0),c}).then(function(b){return isNaN(parseInt(b))?(f.reject("value wrong"),c("value wrong")):(b=parseInt(b),e.set(a,--b))}).then(function(a,b){f.resolve(b),c(null,b)}).fail(function(a){f.reject(a),c(a)}),f},e.decrby=function(a,c,e){var f=this,g=new d(function(b){f.emit("decrby",a,c,b)});return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new d;return c.resolve(0),c}).then(function(b){return isNaN(parseInt(b))?(g.reject("value wrong"),e("value wrong")):(b=parseInt(b),f.set(a,b-c))}).then(function(a,b){g.resolve(b),e(null,b)}).fail(function(a){g.reject(a),e(a)}),g},e}),def("min.hash",["min.utils","min.deps.events"],function(a){if("undefined"!=typeof define&&define.amd)var b=arguments[0],c=arguments[1];else var b=a("min.utils"),c=a("min.deps.events");var d=c.Promise,e={};return e.hset=function(a,c,e,f){var g=this,h=new d(function(){g.emit("hset",a,c,e)});return f=f||b.noop,g.exists(a,function(b,d){if(b)return h.reject(b),f(b);if(d)g.get(a,function(b,d){return b?(h.reject(b),f(b)):(d[c]=e,g.set(a,d,function(b){return b?(h.reject(b),f(b)):(h.resolve(a,c,e),f(null,a,c,e),void 0)}),void 0)});else{var i={};i[c]=e,g.set(a,i,function(b){return b?(h.reject(b),f(b)):(g._keys[a]=1,h.resolve(a,c,e),f(null,a,c,e),void 0)})}}),h},e.hsetnx=function(a,c,e,f){var g=new d,h=this;return f=f||b.noop,h.hexists(a,c,function(b,d){if(b)return g.reject(b),f(b);if(d){var b=new Error("The field of the hash is exists");return g.reject(b),f(b)}h.hset(a,c,e,function(a){a&&(g.reject(a),f(a)),g.resolve("OK"),f(null,"OK")})}),g},e.hmset=function(a,c,e){var f=new d,g=this;e=e||b.noop;var h=Object.keys(c),i=g.multi();return h.forEach(function(b){i.hset(a,b,c[b])}),i.exec(function(a,b){e(null,b),f.resolve(b)}),f},e.hget=function(a,c,e){var f=new d,g=this;return e=e||b.noop,g.hexists(a,c,function(b,d){if(b)return f.reject(b),e(b);if(d)g.get(a).then(function(a){var b=a[c];f.resolve(b),e(null,b)}).fail(function(a){f.reject(a),e(a)});else{var b=new Error("no such field");f.reject(b),e(b)}}),f},e.hmget=function(a,c,e){var f=new d,g=this;e=e||b.noop;var h=[],i=g.multi();return c.forEach(function(b){i.hget(a,b)}),i.exec(function(a,b){return a?(e(a),f.reject(a)):(h=b.map(function(a){return a[0]}),f.resolve(h),e(null,h),void 0)}),f},e.hgetall=function(a,c){var e=new d,f=this;return c=c||b.noop,f.exists(a,function(b,d){if(b)return c(b),e.reject(b);if(!d){var b=new Error("no such key");return c(b),e.reject(b)}f.get(a).then(function(a){e.resolve(a),c(null,a)}).fail(function(){})}),e},e.hdel=function(a,c,e){var f=this,g=new d(function(a,b,c){f.emit("hdel",a,b,c)});return e=e||b.noop,f.hexists(a.field,function(b,d){if(b)return e(b),g.reject(b);if(!d){var b=new Error("no such key");return e(b),g.reject(b)}f.get(a).then(function(b){var d=b[c];delete b[c],f.set(a,b).then(function(){g.resolve(a,c,d),e(null,a,c,d)}).fail(function(a){g.reject(a),e(a)})}).fail(function(a){e(a)})}),g},e.hlen=function(a,c){var e=new d,f=this;return c=c||b.noop,f.exists(a,function(b,d){return b?(e.reject(b),c(b)):(d?f.get(a).then(function(a){var b=Object.keys(a).length;e.resolve(b),c(null,b)}).fail(function(a){e.reject(a),c(a)}):(e.resolve(0),c(null,0)),void 0)}),e},e.hkeys=function(a,c){var e=new d,f=this;return c=c||b.noop,f.exists(a,function(b,d){return b?(e.reject(b),c(b)):(d?f.get(a).then(function(a){var b=Object.keys(a);e.resolve(b),c(null,b)}).fail(function(a){e.reject(a),c(a)}):(e.resolve(0),c(null,0)),void 0)}),e},e.hexists=function(a,c,e){var f=new d,g=this;return e=e||b.noop,g.exists(a).then(function(b){return b?g.get(a):(f.resolve(!1),e(null,!1),void 0)}).then(function(a){a.hasOwnProperty(c)?(f.resolve(!0),e(null,!0)):(f.resolve(!1),e(null,!1))}).fail(function(a){f.reject(a),e(a)}),f},e.hincr=function(a,c,e){var f=this,g=new d(function(b){f.emit("hincr",a,c,b)});return e=e||b.noop,f.hexists(a,c).then(function(a){if(a)return f.hget(a);var b=new d;return b.resolve(0),b}).then(function(b){return isNaN(parseFloat(b))?(g.reject("value wrong"),e("value wrong")):(b=parseFloat(b),f.hset(a,c,++b))}).then(function(a,b,c){g.resolve(c),e(null,c)}).fail(function(a){g.reject(a),e(null,a)}),g},e.hincrby=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("hincr",a,c,b)});return f=f||b.noop,g.hexists(a,c).then(function(a){if(a)return g.hget(a);var b=new d;return b.resolve(0),b}).then(function(b){return isNaN(parseFloat(b))?(h.reject("value wrong"),f("value wrong")):(b=parseFloat(b),g.hset(a,c,b+e))}).then(function(a,b,c){h.resolve(c),f(null,c)}).fail(function(a){h.reject(a),f(null,a)}),h},e.hincrbyfloat=e.hincrby,e.hdecr=function(a,c,e){var f=this,g=new d(function(b){f.emit("hdecr",a,c,b)});return e=e||b.noop,f.hexists(a,c).then(function(b){if(b)return f.hget(a,c);var e=new d;return e.resolve(0),e}).then(function(b){return isNaN(parseFloat(b))?(g.reject("value wrong"),e("value wrong")):(b=parseFloat(b),f.hset(a,c,--b))}).then(function(a,b,c){g.resolve(c),e(null,c)}).fail(function(a){g.reject(a),e(a)}),g},e.hdecrby=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("hincr",a,c,b)});return f=f||b.noop,g.hexists(a,c).then(function(a){if(a)return g.hget(a);var b=new d;return b.resolve(0),b}).then(function(b){return isNaN(parseFloat(b))?(h.reject("value wrong"),f("value wrong")):(b=parseFloat(b),g.hset(a,c,b-e))}).then(function(a,b,c){h.resolve(c),f(null,c)}).fail(function(a){h.reject(a),f(null,a)}),h},e}),def("min.list",["min.utils","min.deps.events"],function(a){if("undefined"!=typeof define&&define.amd)var b=arguments[0],c=arguments[1];else var b=a("min.utils"),c=a("min.deps.events");var d=c.Promise,e={};return e.lpush=function(a,c,e){var f=this,g=new d(function(b){f.emit("lpush",a,b)});return e=e||b.noop,f.exists(a,function(b,d){if(b)return g.reject(b),e(b);if(d)f.get(a,function(b,d){return b?(g.reject(b),e(b)):(d.unshift(c),f.set(a,d,function(a){if(a)return g.reject(a),e(a);var b=d.length;g.resolve(b),e(null,b)}),void 0)});else{var h=[c];f.set(a,h,function(b){return b?(g.reject(b),e(b)):(f._keys[a]=2,g.resolve(1),e(null,1),void 0)})}}),g},e.lpushx=function(a,c,e){var f=new d;e=e||b.noop;var g=this;return g.exists(a,function(b,d){if(b)return f.reject(b),e(b);if(!d){var b=new Error("no such key");return e(b),f.reject(b)}g.get(a,function(b,d){if(b)return f.reject(b),e(b);if(!d.length){var b=new Error("The list is empty.");return e(b),f.reject(b)}d.unshift(c),g.set(a,d,function(a){if(a)return f.reject(a),e(a);var b=d.length;f.resolve(b),e(null,b)})})}),f},e.rpush=function(a,c,e){var f=this,g=new d(function(b){f.emit("rpush",a,b)});return e=e||b.noop,f.exists(a,function(b,d){if(b)return g.reject(b),e(b);if(d)f.get(a,function(b,d){return b?(g.reject(b),e(b)):(d.push(c),f.set(a,d,function(a){if(a)return g.reject(a),e(a);var b=d.length;g.resolve(b),e(null,b)}),void 0)});else{var h=[c];f.set(a,h,function(a){return a?(g.reject(a),e(a)):(g.resolve(1),e(null,1),void 0)})}}),g},e.lpushx=function(a,c,e){var f=new d;e=e||b.noop;var g=this;return g.exists(a,function(b,d){if(b)return f.reject(b),e(b);if(!d){var b=new Error("no such key");return e(b),f.reject(b)}g.get(a,function(b,d){if(b)return f.reject(b),e(b);if(!d.length){var b=new Error("The list is empty.");return e(b),f.reject(b)}d.push(c),g.set(a,d,function(a){if(a)return f.reject(a),e(a);var b=d.length;f.resolve(b),e(null,b)})})}),f},e.lpop=function(a,c){var e=this,f=new d(function(b){e.emit("lpop",a,b)});c=c||b.noop;var g=null;return e.exists(a).then(function(b){return b?e.get(a):(f.resolve(null),c(null,null),void 0)}).then(function(b){return g=b.shift(),e.set(a,b)}).then(function(){f.resolve(g),c(null,g)}).fail(function(a){f.reject(a),c(a)}),f},e.rpop=function(a,c){var e=this,f=new d(function(b){e.emit("rpop",a,b)});c=c||b.noop;var g=null;return e.exists(a).then(function(b){return b?e.get(a):(f.resolve(null),c(null,null),void 0)}).then(function(b){return g=b.pop(),e.set(a,b)}).then(function(){f.resolve(g),c(null,g)}).fail(function(a){f.reject(a),c(a)}),f},e.llen=function(a,c){var e=new d;c=c||b.noop;var f=this;return f.exists(a,function(b,d){return b?(e.reject(b),c(b)):(d?f.get(a,function(a,b){if(a)return e.reject(a),c(a);var d=b.length;e.resolve(d),c(null,d)}):(e.resolve(0),c(null,0)),void 0)}),e},e.lrange=function(a,c,e,f){var g=new d;f=f||b.noop;var h=this;return h.exists(a,function(b,d){return b?(g.reject(b),f(b)):(d?h.get(a,function(a,b){if(a)return g.reject(a),f(a);var d=b.slice(c,e+1);g.resolve(d),f(null,d)}):(g.resolve(null),f(null,null)),void 0)}),g},e.lrem=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("lrem",a,b)});return f=f||b.noop,g.exists(a,function(b,d){return b?(h.reject(b),f(b)):(d?g.get(a,function(a,b){if(a)return h.reject(a),f(a);var d=0;switch(!0){case c>0:for(var g=0;g<b.length&&c>d;g++)if(b[g]===e){{b.splice(g,1)[0]}d++}break;case 0>c:for(var g=b.length-1;g>=0&&c>d;g--)if(b[g]===e){{b.splice(g,1)[0]}d++}break;case c=0:for(var g=b.length-1;g>=0;g--)if(b[g]===e){{b.splice(g,1)[0]}d++}}h.resolve(d),f(null,d)}):(h.resolve(null),f(null,null)),void 0)}),h},e.lset=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("lset",a,b)});return f=f||b.noop,g.exists(a,function(b,d){if(b)return h.reject(b),f(b);if(!d){var b=new Error("no such key");return h.reject(b),f(b)}g.get(a,function(b,d){if(b)return h.reject(b),f(b);if(!d[c]||!d.length){var b=new Error("no such key");return h.reject(b),f(b)}d[c]=e,g.set(a,d,function(a){if(a)return h.reject(a),f(a);var b=d.length;h.resolve(b),f(null,b)})})}),h},e.ltrim=function(a,c,e,f){var g=new d,h=this;return f=f||b.noop,h.exists(a,function(b,d){return b?(g.reject(b),f(b)):(d?h.get(a,function(a,b){if(a)return g.reject(a),f(a);var d=b.splice(c,e+1);g.resolve(d),f(null,d)}):(g.resolve(null),f(null,null)),void 0)}),g},e.lindex=function(a,c,e){var f=new d,g=this;return e=e||b.noop,g.exists(a,function(b,d){return b?(f.reject(b),e(b)):(d?g.get(a,function(a,b){if(a)return f.reject(a),e(a);var d=b[c];f.resolve(d),e(null,d)}):(f.resolve(null),e(null,null)),void 0)}),f},e.linsertBefore=function(a,c,e,f){var g=new d,h=this;return f=f||b.noop,h.exists(a,function(b,d){return b?(g.reject(b),f(b)):(d?h.get(a,function(b,d){if(b)return g.reject(b),f(b);var i=d.indexOf(c);return 0>i?(g.resolve(null),f(null,null)):(d.splice(i,1,e,c),h.set(a,d,function(a){if(a)return g.reject(a),f(a);var b=d.length;g.resolve(b),f(null,b)}),void 0)}):(g.resolve(null),f(null,null)),void 0)}),g},e.linsertAfter=function(a,c,e,f){var g=new d,h=this;return f=f||b.noop,h.exists(a,function(b,d){return b?(g.reject(b),f(b)):(d?h.get(a,function(b,d){if(b)return g.reject(b),f(b);var i=d.indexOf(c);return 0>i?(g.resolve(null),f(null,null)):(d.splice(i,0,e),h.set(a,d,function(a){if(a)return g.reject(a),f(a);var b=d.length;g.resolve(b),f(null,b)}),void 0)}):(g.resolve(null),f(null,null)),void 0)}),g},e.rpoplpush=function(a,c,e){var f=new d,g=this;return e=e||b.noop,g.rpop(a).then(function(a){return g.lpush(c,a)}).then(function(a){f.resolve(value,a),e(null,value,a)}).fail(function(a){e(a),f.reject(a)}),f},e}),def("min.sset",["min.utils","min.deps.events"],function(a){if("undefined"!=typeof define&&define.amd)var b=arguments[0],c=arguments[1];else var b=a("min.utils"),c=a("min.deps.events");var d=c.Promise,e={};return e.sadd=function(a,c){var e=this,f=new d(function(b){e.emit("sadd",a,b)});c=Array.isArray(c)?c:[].slice.call(arguments,1);var g=0;if(c[c.length-1]instanceof Function)var h=c.splice(c.length-1,1)[0];else var h=b.noop;return e.exists(a).then(function(d){if(d)return e.get(a);var f=b.arrayUnique(c);return e.set(a,f)}).then(function(){if(Array.isArray(arguments[0])){for(var b=arguments[0],d=0;d<c.length;d++)!function(a){var d=c[a];b.indexOf(d)>=0||(b.push(d),g++)}(d);return e.set(a,b)}"string"==typeof arguments[0]&&(g+=c.length,e._keys[a]=3,f.resolve(g),h(null,g))}).then(function(){e._keys[a]=3,f.resolve(g),h(null,g)}).fail(function(a){f.reject(a),h(a)}),f},e.srem=function(a,c,e){var f=this,g=new d(function(b){f.emit("srem",a,b)});c=[].slice.call(arguments,1);var h=0;return c[c.length-1]instanceof Function||(e=b.noop),f.exists(a).then(function(b){return b?f.get(a):new Error("no such key")}).then(function(b){for(var d=0;d<c.length;d++)!function(a){var d=c[a],e=b.indexOf(d);e>=0&&(b.splice(e,1),h++)}(d);return f.set(a,b)}).then(function(){f._keys[a]=3,g.resolve(h),e(null,h)}).fail(function(a){g.reject(a),e(a)}),g},e.smembers=function(a,c){var e=new d,f=this;return c=c||b.noop,f.exists(a).then(function(b){return b?f.get(a):new Error("no such key")}).then(function(a){e.resolve(a),c(null,a)}).fail(function(a){e.reject(a),c(a)}),e},e.sismember=function(a,b,c){var e=this,f=new d;return e.exists(a).then(function(b){return b?e.get(a):new Error("no such key")}).then(function(a){var d=a.indexOf(b)>=0?1:0;f.resolve(d),c(null,d)}).fail(function(a){f.reject(a),c(a)}),f},e.scard=function(a,c){var e=new d;c=c||b.noop;var f=this;return f.exists(a).then(function(b){return b?f.get(a):new Error("no such key")}).then(function(a){var b=a.length;e.resolve(b),c(null,b)}).fail(function(a){e.reject(a),c(a)}),e},e.smove=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("smove",a,c,e,b)});return members=[].slice.call(arguments,1),members[members.length-1]instanceof Function||(f=b.noop),g.exists(key).then(function(b){return b?g.sismember(a,e):new Error("no such key")}).then(function(b){return b?g.srem(a,e):new Error("no such member")}).then(function(){return g.sismember(c,e)}).then(function(a){return a?(g._keys[key]=3,h.resolve(0),f(null,0),void 0):g.sadd(c,e)}).then(function(){g._keys[key]=3,h.resolve(1),f(null,1)}).fail(function(a){h.reject(a),f(a)}),h},e.srandmember=function(a,c){var e=new d,f=this;return c=c||b.noop,f.exists(a).then(function(b){return b?f.get(a):(e.resolve(null),c(null,null),void 0)}).then(function(a){var b=Math.random()*a.length|0,d=a[b];e.resolve(d),c(null,d)}).fail(function(a){e.reject(a),c(a)}),e},e.spop=function(a,c){var e=this,f=new d(function(b){e.emit("spop",a,b)});c=c||b.noop;var g=null;return e.exists(a).then(function(b){return b?e.srandmember(a):(f.resolve(null),c(null,null),void 0)}).then(function(b){return g=b,e.srem(a,g)}).then(function(){f.resolve(g),c(null,g)}).fail(function(a){f.reject(a),c(a)}),f},e.sunion=function(a,c){var e=new d,f=this;a=[].slice.call(arguments),a[a.length-1]instanceof Function||(c=b.noop);var g=[];return function h(d){var i=a[d];i?f.exists(i).then(function(a){return a?f.get(i):(h(++d),void 0)}).then(function(a){Array.isArray(a)&&(g=g.concat(a)),h(++d)}).fail(function(a){return e.reject(a),c(a)}):(g=b.arrayUnique(g),e.resolve(g),c(null,g))}(0),e},e.sunionstore=function(a,c,e){var f=new d,g=this;c=[].slice.call(arguments,2),c[c.length-1]instanceof Function||(e=b.noop);var h=null;return g.sunion(c).then(function(b){return h=b,g.exists(a)}).then(function(b){return b?g.del(a):g.sadd(a,h)}).then(function(b){return"number"!=typeof b?g.sadd(a,h):(f.resolve(b,h),e(null,b,h),void 0)}).then(function(a){f.resolve(a,h),e(null,a,h)}).fail(function(a){f.reject(a),e(a)}),f},e.sinter=function(a,c){var e=new d,f=this;a=[].slice.call(arguments),a[a.length-1]instanceof Function||(c=b.noop);var g=[];return function h(d){var i=a[d];if(i)f.exists(i).then(function(a){return a?f.get(i):(h(++d),void 0)}).then(function(a){Array.isArray(a)&&g.push(a),h(++d)}).fail(function(a){return e.reject(a),c(a)});else{var j=b.arrayInter.apply(b,g);e.resolve(j),c(null,j)}}(0),e},e.sinterstore=function(a,c,e){var f=new d,g=this;c=[].slice.call(arguments,1),c[c.length-1]instanceof Function||(e=b.noop);var h=null;return g.sinter.apply(g,c).then(function(b){return h=b,g.exists(a)}).then(function(b){return b?g.del(a):(h.unshift(a),g.sadd.apply(g,h))}).then(function(b){return"string"!=typeof b?g.sadd(a,h):(f.resolve(h.length,h),e(null,h.length,h),void 0)}).then(function(){f.resolve(h.length,h),e(null,h.length,h)}).fail(function(a){f.reject(a),e(a)}),f},e.sdiff=function(a,c){var e=new d,f=this;a=[].slice.call(arguments,1),a[a.length-1]instanceof Function||(c=b.noop);var g=[];return function h(d){var i=a[d];if(i)f.exists(i).then(function(a){return a?f.get(i):(h(++d),void 0)}).then(function(a){Array.isArray(a)&&g.push(a),h(++d)}).fail(function(a){return e.reject(a),c(a)});else{var j=b.arrayDiff.apply(b,g);e.resolve(j),c(null,j)}}(0),e},e.sdiffstore=function(a,c,e){var f=new d,g=this;c=[].slice.call(arguments,2),c[c.length-1]instanceof Function||(e=b.noop);var h=null;return g.sdiff(c).then(function(b){return h=b,g.exists(a)}).then(function(b){return b?g.del(a):g.sadd(a,h)}).then(function(b){return"number"!=typeof b?g.sadd(a,h):(f.resolve(b,h),e(null,b,h),void 0)}).then(function(a){f.resolve(a,h),e(null,a,h)}).fail(function(a){f.reject(a),e(a)}),f},e}),def("min.zset",["min.utils","min.deps.events"],function(a){if("undefined"!=typeof define&&define.amd)var b=arguments[0],c=arguments[1];else var b=a("min.utils"),c=a("min.deps.events");var d=c.Promise,e={};return e.zadd=function(a,c,e,f){var g=this,h=new d(function(a){g.emit("zadd",a)});return f=f||b.noop,g.exists(a).then(function(b){if(b)return g.get(a);var d={};return d[c]=[0],g.set(a,{ms:[e],hsm:{0:c},shm:d})}).then(function(b){if("string"==typeof b)g._keys[a]=4,h.resolve(1,1),f(null,1,1);else if("object"==typeof b){var d=b;if(d.ms.indexOf(e)>=0){var i=d.ms.length;return h.resolve(0,i),f(null,0,i)}var j=d.ms.length;return d.ms.push(e),d.hsm[j]=c,Array.isArray(d.shm[c])?d.shm[c].push(j):d.shm[c]=[j],g.set(a,d)}}).then(function(a,b){g._keys[a]=4;var c=b.ms.length;h.resolve(1,c),f(null,1,c)}).fail(function(a){h.reject(a),f(a)}),h},e.zcard=function(a,c){var e=this,f=new d;return c=c||b.noop,e.exists(a).then(function(b){if(b)return e.get(a);var d=new Error("no such key");f.reject(d),c(d)}).then(function(a){var b=a.ms.filter(Boolean).length;f.resolve(b),c(null,b)}).fail(function(a){f.reject(a),c(a)}),f},e.zcount=function(a,c,e,f){var g=this,h=new d(function(a){g.emit(a)});return f=f||b.noop,g.exists(a).then(function(b){if(b)return g.get(a);var c=new Error("no such key");h.reject(c),f(c)}).then(function(a){var b=Object.keys(a.shm).filter(function(a){return a>=c&&e>=a}).map(function(b){return a.shm[b]}),d=0;b.forEach(function(a){d+=a.length}),h.resolve(d),f(null,d)}).fail(function(a){h.reject(a),f(a)}),h},e.zrem=function(a){var c=this,e=new d(function(a){c.emit("zrem",a)}),f=arguments[arguments.length-1],g=[].slice.call(arguments,1);"function"!=typeof f?f=b.noop:g.pop();var h=0;return c.exists(a).then(function(b){if(b)return c.get(a);var d=new Error("no such key");e.reject(d),f(d)}).then(function(a){for(var b=g.length,c=new d,e=0;e<g.length;e++)!function(d){var e=a.ms.indexOf(g[d]);if(e>=0){a.ms[e]=0;var f=a.hsm[e];delete a.hsm[e];var i=a.shm[f].indexOf(e);i>=0&&a.shm[f].splice(i,1),h++,--b||c.resolve(a)}else b--}(e);return c}).then(function(b){return c.set(a,b)}).then(function(){e.resolve(h),f(null,h)}).fail(function(a){e.reject(a),f(null,a)}),e},e.zscore=function(a,c,e){var f=this,g=new d;return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new Error("no such key");g.reject(c),e(c)}).then(function(a){var b=a.ms.indexOf(c);if(b>=0){var d=a.hsm[b];g.resolve(d),e(null,d)}else{var f=new Error("This member does not be in the set");g.reject(f),e(f)}}),g},e.zrange=function(a,c,e,f){var g=this,h=new d(function(a){g.emit(a)});return f=f||b.noop,g.exists(a).then(function(b){if(b)return g.get(a);var c=new Error("no such key");h.reject(c),f(c)}).then(function(a){var b=Object.keys(a.shm).filter(function(a){return a>=c&&e>=a}).map(function(b){return a.shm[b]}),d=[];b.forEach(function(b){d=d.concat(b.map(function(b){return a.ms[b]}))}),h.resolve(d),f(null,d)}).fail(function(a){h.reject(a),f(a)}),h.withScore=function(c){var e=new d;return c=c||b.noop,h.then(function(b){var d=g.multi();b.forEach(function(b){d.zscore(a,b)}),d.exec(function(a,d){if(a)return c(a),e.reject(a);var f=[];d.forEach(function(a,c){f.push({member:b[c],score:a[0]})}),e.resolve(f),c(null,f)})}),e},h},e.zrevrange=function(a,c,e,f){var g=this,h=new d(function(a){g.emit(a)});return f=f||b.noop,g.exists(a).then(function(b){if(b)return g.get(a);var c=new Error("no such key");h.reject(c),f(c)}).then(function(a){var b=Object.keys(a.shm).reverse().filter(function(a){return a>=c&&e>=a}).map(function(b){return a.shm[b]}),d=[];b.forEach(function(b){d=d.concat(b.map(function(b){return a.ms[b]}))}),h.resolve(d),f(null,d)}).fail(function(a){h.reject(a),f(a)}),h.withScore=function(c){var e=new d;return c=c||b.noop,h.then(function(b){var d=g.multi();b.forEach(function(b){d.zscore(a,b)
  }),d.exec(function(a,d){if(a)return c(a),e.reject(a);var f=[];d.forEach(function(a,c){f.push({member:b[c],score:a[0]})}),e.resolve(f),c(null,f)})}),e},h},e.zincrby=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("zincrby",a,c,e,b)});f=f||b.noop;var i=null;return g.exists(a).then(function(b){return b?g.zscore(a,e):(g.zadd(a,c,e,f).then(h.resolve.bind(h)).fail(h.reject.bind(h)),void 0)}).then(function(){return g.get(a)}).then(function(b){var d=b.ms.indexOf(e),f=b.hsm[d];i=f+c;var h=b.shm[f].indexOf(d);return b.shm[f].splice(h,1),b.hsm[d]=i,b.shm[i]?b.shm[i].push(d):b.shm[i]=[d],g.set(a,b)}).then(function(){h.resolve(i),f(null,i)}).fail(function(a){h.reject(a),f(a)}),h},e.zdecrby=function(a,c,e,f){var g=this,h=new d(function(b){g.emit("zdecrby",a,c,e,b)});f=f||b.noop;var i=null;return g.exists(a).then(function(b){if(b)return g.zscore(a,e);var c=new Error("no such key");return h.reject(c),f(c)}).then(function(){return g.get(a)}).then(function(b){var d=b.ms.indexOf(e),f=b.hsm[d];i=f-c;var h=b.shm[f].indexOf(d);return b.shm[f].splice(h,1),b.hsm[d]=i,b.shm[i]?b.shm[i].push(d):b.shm[i]=[d],g.set(a,b)}).then(function(){h.resolve(i),f(null,i)}).fail(function(a){h.reject(a),f(a)}),h},e.zrank=function(a,c,e){var f=this,g=new d;return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new Error("no such key");return g.reject(c),e(c)}).then(function(a){var b=Object.keys(a.shm),d=a.hsm[a.ms.indexOf(c)],f=b.indexOf(d);g.resolve(f),e(null,f)}).fail(function(a){g.reject(a),e(a)}),g},e.zrevrank=function(a,c,e){var f=this,g=new d;return e=e||b.noop,f.exists(a).then(function(b){if(b)return f.get(a);var c=new Error("no such key");return g.reject(c),e(c)}).then(function(a){var b=Object.keys(a.shm),d=a.hsm[a.ms.indexOf(c)],f=b.reverse().indexOf(d);g.resolve(f),e(null,f)}).fail(function(a){g.reject(a),e(a)}),g},e}),def("min.mise",["min.utils","min.deps.events"],function(a){function b(a){var b=this;this.queue=[],this.last=null,this.state=0,this.min=a;for(var c in a)a.hasOwnProperty(c)&&"function"==typeof a[c]&&!function(a){b[a]=function(){return b.queue.push({method:a,args:arguments}),b}}(c)}function c(a,b,c){var d=this;d.min=b,d.callback=c,d.result=[],d.keys={},d.promise=new g,d.sortFn=function(a,b){return e.isNumber(a)&&e.isNumber(b)?a-b:JSON.stringify(a)>JSON.stringify(b)};var f=function(){d.min.exists(a).then(function(b){return b?d.min.get(a):new Error("no such key")}).then(function(a){var b=new g;switch(!0){case Array.isArray(a):b.resolve(a);break;case a.ms&&Array.isArray(a.ms):b.resolve(a.ms);break;default:return new Error("content type wrong")}return b}).then(function(a){d.result=a.sort(d.sortFn),d.result.forEach(function(a){d.keys[a]=a}),d.promise.resolve(d.result),d.callback(null,d.result)}).fail(function(a){d.promise.reject(a),d.callback(a)})};!function h(a){var b=a.shift();b?(d[b]=function(){return d.promise[b].apply(d.promise,arguments)},h(a)):f()}(["then","fail","done"])}function d(a,b,c,d){b=b||"*",this.cursor=a||0,this.pattern=new RegExp(b.replace("*","(.*)")),this.limit=c>-1?c:10,this.end=this.cursor,this.parent=d}if("undefined"!=typeof define&&define.amd)var e=arguments[0],f=arguments[1];else var e=a("min.utils"),f=a("min.deps.events");var g=f.Promise,h={};return b.prototype.exec=function(a){var b=this,c=[];!function d(e){e?b.min[e.method].apply(b.min,e.args).then(function(){c.push(arguments),d(b.queue.shift())}).fail(function(b){a(b,c)}):a(null,c)}(b.queue.shift())},h.multi=function(){return new b(this)},c.prototype.by=function(a,b){var c=this;b=b||e.noop;var d={},f=[],g=null;if(a.indexOf("->")>0){var h=a.indexOf("->");g=a.substr(h+2),a=a.substr(0,a.length-h)}return c.min.keys(a).then(function(b){for(var e=new RegExp(a.replace("?","(.)").replace("*","(.*)")),g=0;g<b.length;g++){var h=e.exec(b[g])[1];c.result.indexOf(h)>=0&&(d[b[g]]=h)}return f=Object.keys(d),c.min.mget(f.slice())}).then(function(a){for(var e={},g=0;g<a.length;g++)e[JSON.stringify(a[g])]=f[g];a.sort(c.sortFn);var h=a.map(function(a){return e[JSON.stringify(a)]}).map(function(a){return d[a]});c.result=h,c.promise.resolve(h),b(null,h)}).fail(function(a){c.promise.reject(a),b(a),c.callback(a)}),this},c.prototype.asc=function(a){var b=this;a=a||e.noop,b.sortFn=function(a,b){return e.isNumber(a)&&e.isNumber(b)?a-b:JSON.stringify(a)>JSON.stringify(b)};var c=function(c){b.result=c.sort(b.sortFn),b.promise.resolve(b.result),a(null,b.result)};return b.promise.ended?c(b.result):b.promise.once("resolve",c),b},c.prototype.desc=function(a){var b=this;a=a||e.noop,b.sortFn=function(a,b){return e.isNumber(a)&&e.isNumber(b)?b-a:JSON.stringify(a)<JSON.stringify(b)};var c=function(c){b.result=c.sort(b.sortFn),b.promise.resolve(b.result),a(null,b.result)};return b.promise.ended?c(b.result):b.promise.once("resolve",c),b},c.prototype.get=function(a,b){var c=this;b=b||e.noop;var d=function(d){var f=[];!function g(d){var h=d.shift();if(e.isUndefined(h))c.result=f,c.promise.resolve(f),b(null,f);else if(Array.isArray(h)){var i=c.keys[h[0]];c.min.get(a.replace("*",i)).then(function(a){h.push(a),f.push(h),g(d)}).fail(function(a){c.promise.reject(a),b(a)})}else if(h.substr||e.isNumber(h)){var i=c.keys[h];c.min.get(a.replace("*",i)).then(function(a){f.push([a]),a.substr||e.isNumber(a)?c.keys[a]=i:c.keys[JSON.stringify(a)]=i,g(d)}).fail(function(a){c.promise.reject(a),b(a)})}}(d.slice())};return c.promise.ended?d(c.result):c.promise.once("resolve",d),this},c.prototype.hget=function(a,b,c){c=c||e.noop;var d=this,f=function(f){var g=[];!function h(f){var i=f.shift();if(e.isUndefined(i))d.result=g,d.promise.resolve(g),c(null,g);else if(Array.isArray(i)){var j=d.keys[i[0]];d.min.hget(a.replace("*",j),b).then(function(a){i.push(a),g.push(i),h(f)}).fail(function(a){d.promise.reject(a),c(a)})}else if(i.substr||e.isNumber(i)){var j=d.keys[i];d.min.hget(a.replace("*",j)).then(function(a){g.push([a]),a.substr||e.isNumber(a)?d.keys[a]=j:d.keys[JSON.stringify(a)]=j,h(f)}).fail(function(a){d.promise.reject(a),c(a)})}}(f.slice())};return d.promise.ended?f(d.result):d.promise.once("resolve",f),this},c.prototype.limit=function(a,b,c){c=c||e.noop;var d=this,f=function(e){d.result=e.splice(a,b),d.promise.resolve(d.result),c(null,d.result)};return d.promise.ended?f(d.result):d.promise.once("resolve",f),this},c.prototype.flatten=function(a){a=a||e.noop;var b=this;if(b.promise.ended){for(var c=[],d=0;d<b.result.length;d++)for(var f=0;f<b.result[d].length;f++)c.push(b.result[d][f]);b.result=c,b.promise.resolve(c),a(null,c)}else b.promise.once("resolve",function(c){for(var d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].length;f++)d.push(c[e][f]);b.result=d,b.promise.resolve(d),a(null,d)});return this},c.prototype.store=function(a,b){var c=this;return b=b||e.noop,c.promise.ended?c.min.set(a,c.result).then(function(){c.promise.resolve(c.result),b(null,c.result)}).fail(function(a){c.promise.reject(a),b(a)}):c.promise.once("resolve",function(d){c.min.set(a,d).then(function(){c.promise.resolve(d),b(null,d)}).fail(function(a){c.promise.reject(a),b(a)})}),this},h.sort=function(a,b){return b=b||e.noop,new c(a,this,b)},d.prototype.scan=function(a){var b=this,c=[];return b.parent.get("min_keys").then(function(d){d=JSON.parse(d);var e=Object.keys(d);!function f(d){var g=e[d];if(g&&b.pattern.test(g)&&"min_keys"!==g){if(c.push(g),++b.end-b.cursor>=b.limit)return a(null,c,b.end)}else if(!g)return b.end=0,a(null,c,b.end);return f(++d)}(b.cursor)},function(b){a(b)}),this},d.prototype.match=function(a,b){return this.pattern=new RegExp(a.replace("*","(.*)")),this.end=this.cursor,this.scan(b||e.noop)},d.prototype.count=function(a,b){return this.limit=a,this.end=this.cursor,this.scan(b||e.noop)},h.scan=function(a,b){var c=this;b=b||e.noop;var f=new d(a,null,-1,c);return f.scan(b),f},h}),def("min",["min.utils","min.deps.events","min.mix","min.hash","min.list","min.sset","min.zset","min.mise"],function(a){function b(){}function c(){}if("undefined"!=typeof define&&define.amd)var d=arguments[0],e=arguments[1],f=arguments[2],g=arguments[3],h=arguments[4],i=arguments[5],j=arguments[6],k=arguments[7];else var d=a("min.utils"),e=a("min.deps.events"),f=a("min.mix"),g=a("min.hash"),h=a("min.list"),i=a("min.sset"),j=a("min.zset"),k=a("min.mise");var l=e.Promise,m={};d.extend(m,new e.EventEmitter),b.prototype.get=function(a){return sessionStorage?sessionStorage.getItem(a):!1},b.prototype.set=function(a,b){return sessionStorage?sessionStorage.setItem(a,b):!1},b.prototype.remove=function(a){return sessionStorage?sessionStorage.removeItem(a):!1},c.prototype.get=function(a){return localStorage?localStorage.getItem(a):!1},c.prototype.set=function(a,b){return localStorage?localStorage.setItem(a,b):!1},c.prototype.remove=function(a){return localStorage?localStorage.removeItem(a):!1},m.memStore=b,m.localStore=c,m.store=new m.localStore;var n=m._keys={},o=null,p={0:"mix",1:"hash",2:"list",3:"set",4:"zset"};return m.fork=function(){var a={};for(var b in this)this.hasOwnProperty(b)&&(a[b]=this[b]);return a},m.del=function(a,b){var c=this,e=new l(function(){c.emit("del",a),o&&clearTimeout(o),o=setTimeout(c.save.bind(c),5e3)}),f=this.store;"undefined"==typeof b&&(b=d.noop);var g="min-"+a;if(f.async){var h=function(){f.remove(g,function(d){return d?(e.reject(d),b(d)):(delete c._keys[a],e.resolve(a),b(null,a),void 0)})};f.ready?h():f.on("ready",h)}else try{f.remove(g),delete c._keys[a],e.resolve(a),b(null,a)}catch(i){e.reject(i),b(i)}return this.emit("del",a),e},m.exists=function(a,b){var c=new l;b=b||d.noop;try{this.get(a,function(a,d){return a&&(c.resolve(!1),b(null,!1)),"undefined"==typeof d?(c.resolve(!1),b(null,!1)):(c.resolve(!0),b(null,!0))})}catch(e){return c.reject(e),b(e)}return c},m.renamenx=function(a,b,c){var e=this,f=new l(function(){o&&clearTimeout(o),o=setTimeout(e.save.bind(e),5e3)});"undefined"==typeof c&&(c=d.noop);try{var g=function(a){f.reject(a),c(a)},h=null,i=null;m.exists(a).then(function(b){if(b)return m.get(a);var c=new Error("no such key");g(c)}).then(function(b){return h=e._keys[a],i=b,m.del(a)}).then(function(){return m.set(b,i,c)}).then(function(){e._keys[b]=h,f.resolve("OK"),c(null,"OK")}).fail(g)}catch(j){g(j)}return f},m.rename=function(a,b,c){var e=this,f=new l(function(){o&&clearTimeout(o),o=setTimeout(e.save.bind(e),5e3)}),g=function(a){f.reject(a),c(a)};return"undefined"==typeof c&&(c=d.noop),a==b?g(new Error("The key is equal to the new key.")):e.renamenx.apply(e,arguments).then(f.resolve.bind(f)).fail(f.reject.bind(f)),f},m.keys=function(a,b){var c=new l,e=Object.keys(this._keys);b=b||d.noop;var f=a.replace("?","(.)").replace("*","(.*)");f=new RegExp(f);for(var g=[],h=0;h<e.length;h++)e[h].match(f)&&g.push(e[h]);return c.resolve(g),b(null,g),c},m.randomkey=function(a){var b=new l,c=Object.keys(this._keys);"undefined"==typeof a&&(a=d.noop);var e=Math.round(Math.random()*(c.length-1)),f=c[e];return b.resolve(f),a(null,f),b},m.type=function(a,b){var c=new l;return b=b||d.noop,this._keys.hasOwnProperty(a)?(c.resolve(p[this._keys[a]]),b(null,b)):(c.resolve(null),b(null,null)),c},m.empty=function(a){var b=this,c=new l(function(a){b.emit("empty",a),o&&clearTimeout(o),o=setTimeout(b.save.bind(b),5e3)}),e=Object.keys(this._keys),f=0;return a=a||d.noop,function g(d){d?b.del(d,function(a){a||f++,g(e.shift())}):(c.resolve(f),a(null,f))}(e.shift()),c},m.save=function(a){var b=this,c=new l(function(a,c){b.emit("save",a,c)});return a=a||d.noop,b.set("min_keys",JSON.stringify(b._keys)).then(function(){return b.dump()}).then(function(b,d){c.resolve(b,d),a(b,d)}).fail(function(b){c.reject(b),a(b)}),c},m.dump=function(a){var b=this,c=new l;a=a||d.noop;var e={};return b.keys("*").then(function(d){!function f(g){if(g)b.get(g).then(function(a){e[g]=a,f(d.shift())}).fail(function(b){c.reject(b),a(b)});else{var h=JSON.stringify(e);c.resolve(e,h),a(null,e,h)}}(d.shift())}).fail(function(b){c.reject(b),a(b)}),c},m.restore=function(a,b){var c=this,e=new l(function(){c.save(function(){c.emit("restore")})});b=b||d.noop;var f=Object.keys(a);return function g(d,h){d?c.set(d,a[d]).then(function(){g(f.shift(),h)}).fail(function(a){e.reject(a),b(a)}):h()}(f.shift(),function(){c.exists("min_keys").then(function(a){return a?c.get("min_keys"):(e.resolve(),b(),void 0)}).then(function(a){n=JSON.parse(a),e.resolve(),b()})}),e},d.extend(m,g),d.extend(m,h),d.extend(m,i),d.extend(m,j),d.extend(m,k),d.extend(m,f),m.exists("min_keys").then(function(a){return a?m.get("min_keys"):void 0}).then(function(a){m._keys=JSON.parse(a)}),m});
  //# sourceMappingURL=min.js.source