text: !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ACQ=t()}}((function(){return function t(e,n,r){function o(u,c){if(!n[u]){if(!e[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var a=n[u]={exports:{}};e[u][0].call(a.exports,(function(t){return o(e[u][1][t]||t)}),a,a.exports,t,e,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(t,e,n){var r=t("./cache"),o=t("./concurrency"),i=t("./timeout"),u=t("./container");function c(t,e){return t&&e?function(n){return e(t(n))}:t||e}n.queueFactory=function(t){var e=t||{},n=e.cache,u=e.concurrency,f=e.negativeCache,s=e.storage,a=e.timeout,l=e.timeoutFallback,h=null;return a&&(h=c(h,i.timeoutFactory(a,l))),u&&(h=c(h,o.concurrencyFactory(u))),(n||f||s)&&(h=c(h,r.cacheFactory(t))),h||(h=function(t){return function(e){return Promise.resolve().then((function(){return t(e)}))}}),function(t){return h(t)}},n.clearCache=function(){u.clearContainers()}},{"./cache":2,"./concurrency":3,"./container":4,"./timeout":6}],2:[function(t,e,n){var r=t("./data-storage"),o=t("./container");n.cacheFactory=function(t){var e=t.cache,n=t.hasher,i=t.maxItems,u=t.negativeCache,c=t.refresh,f=t.storage;if(e=+e||0,u=+u||0,(c=+c||0)<0)throw new Error("Invalid refresh: "+c);if(null==n&&(n=function(t){return JSON.stringify(t)}),"function"!=typeof n)throw new Error("Invalid hasher: "+n);return function(t){var s=o.objectFactory((function(){return{}})),a=r.getStorage(e,i),l=r.getStorage(u,i);return function(e){var r=n(e),o=s();return function(){var t=o[r]||a&&a().getItem(r)||l&&l().getItem(r);if(!t)return o[r]=i();c&&Date.now()>t.refresh&&(delete t.refresh,i());return t}().value;function i(){var n={value:f?Promise.resolve().then((function(){return f.get(r)})).then((function(n){return null!=n?n:Promise.resolve().then((function(){return t(e)})).then((function(t){return null==t?t:Promise.resolve().then((function(){return f.set(r,t)})).then((function(){return t}))}))})):Promise.resolve().then((function(){return t(e)}))};return c>0&&(n.refresh=Date.now()+c),n.value.then((function(){if(a)return a().setItem(r,n)}),(function(){if(l)return l().setItem(r,n)})).then((function(){c>0&&(n.refresh=Date.now()+c),delete o[r]})),n}}}}},{"./container":4,"./data-storage":5}],3:[function(t,e,n){n.concurrencyFactory=function(t){if(!(t>0))throw new Error("Invalid concurrency: "+t);return function(e){var n=[],r=0;return function(t){return new Promise((function(i,u){n.push((function(){return r++,Promise.resolve().then((function(){return e(t)})).then(i,u)})),o()}))};function o(){if(!(r>=t)){var e=n.shift();e&&e().then(i,i)}}function i(){r--,o()}}}},{}],4:[function(t,e,n){var r=1;n.clearContainers=function(){r++},n.objectFactory=function(t){var e;return function(){return e&&e[r]||((e={})[r]=t())}}},{}],5:[function(t,e,n){var r=t("timed-kvs"),o=t("./container"),i=function(){function t(){this.items={}}return t.prototype.getItem=function(t){return this.items[t]},t.prototype.setItem=function(t,e){this.items[t]=e},t}();n.getStorage=function(t,e){return t>0||e>0?o.objectFactory((function(){return new r.TimedKVS({expires:t,maxItems:e})})):t<0?o.objectFactory((function(){return new i})):void 0}},{"./container":4,"timed-kvs":7}],6:[function(t,e,n){n.timeoutFactory=function(t,e){if(!(t>0))throw new Error("Invalid timeout: "+t);if(null==e&&(e=function(){return Promise.reject(new Error("timeout: "+t+"ms"))}),"function"!=typeof e)throw new Error("Invalid timeoutFallback: "+e);return function(n){return function(r){return new Promise((function(o,i){var u=0,c=setTimeout((function(){if(c=null,!u++)return Promise.resolve().then((function(){return e(r)})).then(o,i)}),t);Promise.resolve().then((function(){return n(r)})).then((function(t){c&&clearTimeout(c),u++||o(t)}),(function(t){c&&clearTimeout(c),u++||i(t)}))}))}}}},{}],7:[function(t,e,n){var r,o,i;o="timed-kvs",i=(r={}).require=function(t){return r[t]},void 0!==n&&(r[o]=n),function(t){var e,n=this&&this.__extends||(e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)});t("linked-kvs",["require","exports"],(function(t,e){var n=function(){function t(){this.latest=null,this.items={},this.length=0}return t.prototype.get=function(t){var e=this.getItem(t);if(e)return e.value},t.prototype.set=function(t,e){this.setItem(t,{value:e})},t.prototype.getItem=function(t){var e=this.items[t];if(e&&!e.deleted)return e},t.prototype.setItem=function(t,e){var n=e;this.delete(t),this.items[t]=n,this.length++,n.key=t;var r=this.latest;r&&(n.next=r.deleted?r.next:r),this.latest=n},t.prototype.size=function(){return this.length},t.prototype.shrink=function(t){for(var e=this.latest;e;){if(0>=t)return void this.truncate(e);e.deleted||t--,e=e.next}},t.prototype.delete=function(t){var e=this.getItem(t);e&&this._delete(e)},t.prototype._delete=function(t){if(t){t.deleted||(delete this.items[t.key],this.length--,t.key=t.value=null,t.deleted=!0);for(var e=t.next;e&&e.deleted;)e=t.next=e.next}},t.prototype.truncate=function(t){for(var e=t;e;)this._delete(e),e=e.next},t.prototype.all=function(){for(var t=[],e=this.latest;e;){if(!e.deleted){var n=this.getItem(e.key);n&&t.push(n)}e=e.next}return t.reverse()},t.prototype.keys=function(){return this.all().map((function(t){return t.key}))},t.prototype.values=function(){return this.all().map((function(t){return t.value}))},t}();e.LinkedKVS=n})),t("timed-kvs",["require","exports","linked-kvs"],(function(t,e,r){var o=function(t){var e=t.prototype;function r(e){var n=t.call(this)||this,r=e||{},o=r.expires,i=r.maxItems;return n.expires=o>0&&+o||0,n.maxItems=i>0&&+i||0,n}return n(r,t),r.prototype.getItem=function(t){var n=this.expires,r=e.getItem.call(this,t);if(r)return n&&Date.now()>r.ttl?void this.truncate(r):r},r.prototype.setItem=function(t,n){var r=this,o=this.expires,i=this.maxItems;if(o){this.firstKey?!this.getItem(this.firstKey)&&(this.firstKey=void 0):this.firstKey=t;var u=Date.now();n.ttl=u+o}if(e.setItem.call(this,t,n),i){if(this.gcTimeout||i>=this.size())return;var c=Math.min(i,1e3);this.gcTimeout=setTimeout((function(){r.shrink(i),delete r.gcTimeout}),c)}},r}(r.LinkedKVS);e.TimedKVS=o}))}((function(t,e,n){r.exports=r[t]||(r[t]={}),n.apply(null,e.map(i))})),r[o].TimedKVS},{}]},{},[1])(1)}));