!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["tiny-lru"]=e()}(this,(function(){"use strict";class t{constructor(t=0,e=0){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.size=0,this.ttl=e}has(t){return t in this.items}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}evict(){const t=this.first;return delete this.items[t.key],this.first=t.next,this.first.prev=null,this.size--,this}get(t){let e;if(this.has(t)){const s=this.items[t];this.ttl>0&&s.expiry<=(new Date).getTime()?this.delete(t):(e=s.value,this.set(t,e,!0))}return e}keys(){return Object.keys(this.items)}set(t,e,s=!1){let i;if(s||this.has(t)){if(i=this.items[t],i.value=e,!1===s&&(i.expiry=this.ttl>0?(new Date).getTime()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,s=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==s&&(s.next=e),null!==e&&(e.prev=s)}}else this.max>0&&this.size===this.max&&this.evict(),i=this.items[t]={expiry:this.ttl>0?(new Date).getTime()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}}return function(e=1e3,s=0){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(s)||s<0)throw new TypeError("Invalid ttl value");return new t(e,s)}}));