2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
var h=Object.defineProperty;var r=(u,e)=>h(u,"name",{value:e,configurable:!0});var o=class extends Map{get(e){return super.get(e)}set(e,i){return super.set(e,i)}has(e){return super.has(e)}delete(e){return super.delete(e)}clear(){return super.clear()}hasAll(...e){return e.every(i=>super.has(i))}hasAny(...e){return e.some(i=>super.has(i))}first(e){if(typeof e=="undefined")return this.values().next().value;if(e<0)return this.last(e*-1);e=Math.min(this.size,e);let i=this.values();return Array.from({length:e},()=>i.next().value)}firstKey(e){if(typeof e=="undefined")return this.keys().next().value;if(e<0)return this.lastKey(e*-1);e=Math.min(this.size,e);let i=this.keys();return Array.from({length:e},()=>i.next().value)}last(e){let i=[...this.values()];return typeof e=="undefined"?i[i.length-1]:e<0?this.first(e*-1):e?i.slice(-e):[]}lastKey(e){let i=[...this.keys()];return typeof e=="undefined"?i[i.length-1]:e<0?this.firstKey(e*-1):e?i.slice(-e):[]}random(e){let i=[...this.values()];return typeof e=="undefined"?i[Math.floor(Math.random()*i.length)]:!i.length||!e?[]:Array.from({length:Math.min(e,i.length)},()=>i.splice(Math.floor(Math.random()*i.length),1)[0])}randomKey(e){let i=[...this.keys()];return typeof e=="undefined"?i[Math.floor(Math.random()*i.length)]:!i.length||!e?[]:Array.from({length:Math.min(e,i.length)},()=>i.splice(Math.floor(Math.random()*i.length),1)[0])}find(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,l]of this)if(e(l,t,this))return l}findKey(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,l]of this)if(e(l,t,this))return t}sweep(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=this.size;for(let[l,n]of this)e(n,l,this)&&this.delete(l);return t-this.size}filter(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=new this.constructor[Symbol.species];for(let[l,n]of this)e(n,l,this)&&t.set(l,n);return t}partition(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=[new this.constructor[Symbol.species],new this.constructor[Symbol.species]];for(let[l,n]of this)e(n,l,this)?t[0].set(l,n):t[1].set(l,n);return t}flatMap(e,i){let t=this.map(e,i);return new this.constructor[Symbol.species]().concat(...t)}map(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=this.entries();return Array.from({length:this.size},()=>{let[l,n]=t.next().value;return e(n,l,this)})}mapValues(e,i){typeof i!="undefined"&&(e=e.bind(i));let t=new this.constructor[Symbol.species];for(let[l,n]of this)t.set(l,e(n,l,this));return t}some(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,l]of this)if(e(l,t,this))return!0;return!1}every(e,i){typeof i!="undefined"&&(e=e.bind(i));for(let[t,l]of this)if(!e(l,t,this))return!1;return!0}reduce(e,i){let t;if(typeof i!="undefined"){t=i;for(let[n,s]of this)t=e(t,s,n,this);return t}let l=!0;for(let[n,s]of this){if(l){t=s,l=!1;continue}t=e(t,s,n,this)}if(l)throw new TypeError("Reduce of empty collection with no initial value");return t}each(e,i){return this.forEach(e,i),this}tap(e,i){return typeof i!="undefined"&&(e=e.bind(i)),e(this),this}clone(){return new this.constructor[Symbol.species](this)}concat(...e){let i=this.clone();for(let t of e)for(let[l,n]of t)i.set(l,n);return i}equals(e){if(!e)return!1;if(this===e)return!0;if(this.size!==e.size)return!1;for(let[i,t]of this)if(!e.has(i)||t!==e.get(i))return!1;return!0}sort(e=o.defaultSort){let i=[...this.entries()];i.sort((t,l)=>e(t[1],l[1],t[0],l[0])),super.clear();for(let[t,l]of i)super.set(t,l);return this}intersect(e){let i=new this.constructor[Symbol.species];for(let[t,l]of e)this.has(t)&&i.set(t,l);return i}difference(e){let i=new this.constructor[Symbol.species];for(let[t,l]of e)this.has(t)||i.set(t,l);for(let[t,l]of this)e.has(t)||i.set(t,l);return i}sorted(e=o.defaultSort){return new this.constructor[Symbol.species](this).sort((i,t,l,n)=>e(i,t,l,n))}toJSON(){return[...this.values()]}static defaultSort(e,i){return Number(e>i)||Number(e===i)-1}},c=o;r(c,"Collection"),"constructor",c.default=o;var f=c;export{c as Collection,f as default};
|
|
//# sourceMappingURL=index.mjs.map
|