@discordjs/collection 3.0.0-dev.1768521706-3d7412221 → 3.0.0-dev.1769083302-838cd2da3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -173,22 +173,22 @@ var Collection = class _Collection extends Map {
173
173
  reverse() {
174
174
  const entries = [...this.entries()].reverse();
175
175
  this.clear();
176
- for (const [key, value] of entries) this.set(key, value);
176
+ for (const { 0: key, 1: value } of entries) this.set(key, value);
177
177
  return this;
178
178
  }
179
179
  find(fn, thisArg) {
180
180
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
181
181
  if (thisArg !== void 0) fn = fn.bind(thisArg);
182
- for (const [key, val] of this) {
183
- if (fn(val, key, this)) return val;
182
+ for (const { 0: key, 1: value } of this) {
183
+ if (fn(value, key, this)) return value;
184
184
  }
185
185
  return void 0;
186
186
  }
187
187
  findKey(fn, thisArg) {
188
188
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
189
189
  if (thisArg !== void 0) fn = fn.bind(thisArg);
190
- for (const [key, val] of this) {
191
- if (fn(val, key, this)) return key;
190
+ for (const { 0: key, 1: value } of this) {
191
+ if (fn(value, key, this)) return key;
192
192
  }
193
193
  return void 0;
194
194
  }
@@ -197,9 +197,8 @@ var Collection = class _Collection extends Map {
197
197
  if (thisArg !== void 0) fn = fn.bind(thisArg);
198
198
  const entries = [...this.entries()];
199
199
  for (let index = entries.length - 1; index >= 0; index--) {
200
- const val = entries[index][1];
201
- const key = entries[index][0];
202
- if (fn(val, key, this)) return val;
200
+ const { 0: key, 1: value } = entries[index];
201
+ if (fn(value, key, this)) return value;
203
202
  }
204
203
  return void 0;
205
204
  }
@@ -208,9 +207,8 @@ var Collection = class _Collection extends Map {
208
207
  if (thisArg !== void 0) fn = fn.bind(thisArg);
209
208
  const entries = [...this.entries()];
210
209
  for (let index = entries.length - 1; index >= 0; index--) {
211
- const key = entries[index][0];
212
- const val = entries[index][1];
213
- if (fn(val, key, this)) return key;
210
+ const { 0: key, 1: value } = entries[index];
211
+ if (fn(value, key, this)) return key;
214
212
  }
215
213
  return void 0;
216
214
  }
@@ -218,8 +216,8 @@ var Collection = class _Collection extends Map {
218
216
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
219
217
  if (thisArg !== void 0) fn = fn.bind(thisArg);
220
218
  const previousSize = this.size;
221
- for (const [key, val] of this) {
222
- if (fn(val, key, this)) this.delete(key);
219
+ for (const { 0: key, 1: value } of this) {
220
+ if (fn(value, key, this)) this.delete(key);
223
221
  }
224
222
  return previousSize - this.size;
225
223
  }
@@ -227,8 +225,8 @@ var Collection = class _Collection extends Map {
227
225
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
228
226
  if (thisArg !== void 0) fn = fn.bind(thisArg);
229
227
  const results = new this.constructor[Symbol.species]();
230
- for (const [key, val] of this) {
231
- if (fn(val, key, this)) results.set(key, val);
228
+ for (const { 0: key, 1: value } of this) {
229
+ if (fn(value, key, this)) results.set(key, value);
232
230
  }
233
231
  return results;
234
232
  }
@@ -239,11 +237,11 @@ var Collection = class _Collection extends Map {
239
237
  new this.constructor[Symbol.species](),
240
238
  new this.constructor[Symbol.species]()
241
239
  ];
242
- for (const [key, val] of this) {
243
- if (fn(val, key, this)) {
244
- results[0].set(key, val);
240
+ for (const { 0: key, 1: value } of this) {
241
+ if (fn(value, key, this)) {
242
+ results[0].set(key, value);
245
243
  } else {
246
- results[1].set(key, val);
244
+ results[1].set(key, value);
247
245
  }
248
246
  }
249
247
  return results;
@@ -258,7 +256,7 @@ var Collection = class _Collection extends Map {
258
256
  const iter = this.entries();
259
257
  const results = new Array(this.size);
260
258
  for (let index = 0; index < this.size; index++) {
261
- const [key, value] = iter.next().value;
259
+ const { 0: key, 1: value } = iter.next().value;
262
260
  results[index] = fn(value, key, this);
263
261
  }
264
262
  return results;
@@ -267,22 +265,22 @@ var Collection = class _Collection extends Map {
267
265
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
268
266
  if (thisArg !== void 0) fn = fn.bind(thisArg);
269
267
  const coll = new this.constructor[Symbol.species]();
270
- for (const [key, val] of this) coll.set(key, fn(val, key, this));
268
+ for (const { 0: key, 1: value } of this) coll.set(key, fn(value, key, this));
271
269
  return coll;
272
270
  }
273
271
  some(fn, thisArg) {
274
272
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
275
273
  if (thisArg !== void 0) fn = fn.bind(thisArg);
276
- for (const [key, val] of this) {
277
- if (fn(val, key, this)) return true;
274
+ for (const { 0: key, 1: value } of this) {
275
+ if (fn(value, key, this)) return true;
278
276
  }
279
277
  return false;
280
278
  }
281
279
  every(fn, thisArg) {
282
280
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
283
281
  if (thisArg !== void 0) fn = fn.bind(thisArg);
284
- for (const [key, val] of this) {
285
- if (!fn(val, key, this)) return false;
282
+ for (const { 0: key, 1: value } of this) {
283
+ if (!fn(value, key, this)) return false;
286
284
  }
287
285
  return true;
288
286
  }
@@ -296,7 +294,7 @@ var Collection = class _Collection extends Map {
296
294
  } else {
297
295
  accumulator = initialValue;
298
296
  }
299
- for (const [key, value] of iterator) {
297
+ for (const { 0: key, 1: value } of iterator) {
300
298
  accumulator = fn(accumulator, value, key, this);
301
299
  }
302
300
  return accumulator;
@@ -315,16 +313,15 @@ var Collection = class _Collection extends Map {
315
313
  index = entries.length;
316
314
  }
317
315
  while (--index >= 0) {
318
- const key = entries[index][0];
319
- const val = entries[index][1];
320
- accumulator = fn(accumulator, val, key, this);
316
+ const { 0: key, 1: value } = entries[index];
317
+ accumulator = fn(accumulator, value, key, this);
321
318
  }
322
319
  return accumulator;
323
320
  }
324
321
  each(fn, thisArg) {
325
322
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
326
323
  if (thisArg !== void 0) fn = fn.bind(thisArg);
327
- for (const [key, value] of this) {
324
+ for (const { 0: key, 1: value } of this) {
328
325
  fn(value, key, this);
329
326
  }
330
327
  return this;
@@ -358,7 +355,7 @@ var Collection = class _Collection extends Map {
358
355
  concat(...collections) {
359
356
  const newColl = this.clone();
360
357
  for (const coll of collections) {
361
- for (const [key, val] of coll) newColl.set(key, val);
358
+ for (const { 0: key, 1: value } of coll) newColl.set(key, value);
362
359
  }
363
360
  return newColl;
364
361
  }
@@ -374,7 +371,7 @@ var Collection = class _Collection extends Map {
374
371
  if (!collection) return false;
375
372
  if (this === collection) return true;
376
373
  if (this.size !== collection.size) return false;
377
- for (const [key, value] of this) {
374
+ for (const { 0: key, 1: value } of this) {
378
375
  const otherValue = collection.get(key);
379
376
  if (otherValue !== value || otherValue === void 0 && !collection.has(key)) {
380
377
  return false;
@@ -398,7 +395,7 @@ var Collection = class _Collection extends Map {
398
395
  const entries = [...this.entries()];
399
396
  entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
400
397
  super.clear();
401
- for (const [key, value] of entries) {
398
+ for (const { 0: key, 1: value } of entries) {
402
399
  super.set(key, value);
403
400
  }
404
401
  return this;
@@ -418,7 +415,7 @@ var Collection = class _Collection extends Map {
418
415
  */
419
416
  intersection(other) {
420
417
  const coll = new this.constructor[Symbol.species]();
421
- for (const [key, value] of this) {
418
+ for (const { 0: key, 1: value } of this) {
422
419
  if (other.has(key)) coll.set(key, value);
423
420
  }
424
421
  return coll;
@@ -441,7 +438,7 @@ var Collection = class _Collection extends Map {
441
438
  */
442
439
  union(other) {
443
440
  const coll = new this.constructor[Symbol.species](this);
444
- for (const [key, value] of other) {
441
+ for (const { 0: key, 1: value } of other) {
445
442
  if (!coll.has(key)) coll.set(key, value);
446
443
  }
447
444
  return coll;
@@ -462,7 +459,7 @@ var Collection = class _Collection extends Map {
462
459
  */
463
460
  difference(other) {
464
461
  const coll = new this.constructor[Symbol.species]();
465
- for (const [key, value] of this) {
462
+ for (const { 0: key, 1: value } of this) {
466
463
  if (!other.has(key)) coll.set(key, value);
467
464
  }
468
465
  return coll;
@@ -482,10 +479,10 @@ var Collection = class _Collection extends Map {
482
479
  */
483
480
  symmetricDifference(other) {
484
481
  const coll = new this.constructor[Symbol.species]();
485
- for (const [key, value] of this) {
482
+ for (const { 0: key, 1: value } of this) {
486
483
  if (!other.has(key)) coll.set(key, value);
487
484
  }
488
- for (const [key, value] of other) {
485
+ for (const { 0: key, 1: value } of other) {
489
486
  if (!this.has(key)) coll.set(key, value);
490
487
  }
491
488
  return coll;
@@ -591,7 +588,7 @@ var Collection = class _Collection extends Map {
591
588
  */
592
589
  static combineEntries(entries, combine) {
593
590
  const coll = new this[Symbol.species]();
594
- for (const [key, value] of entries) {
591
+ for (const { 0: key, 1: value } of entries) {
595
592
  if (coll.has(key)) {
596
593
  coll.set(key, combine(coll.get(key), value, key));
597
594
  } else {
@@ -610,7 +607,7 @@ var Collection = class _Collection extends Map {
610
607
  };
611
608
 
612
609
  // src/index.ts
613
- var version = "3.0.0-dev.1768521706-3d7412221";
610
+ var version = "3.0.0-dev.1769083302-838cd2da3";
614
611
  // Annotate the CommonJS export names for ESM import in node:
615
612
  0 && (module.exports = {
616
613
  Collection,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/collection.ts"],"sourcesContent":["export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\nexport const version = '3.0.0-dev.1768521706-3d7412221' as string;\n","/* eslint-disable no-param-reassign */\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<Key, Value> = Omit<\n\tCollection<Key, Value>,\n\tkeyof Map<Key, Value> | 'ensure' | 'reverse' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<Key, Value>;\n\nexport interface Collection<Key, Value> {\n\t/**\n\t * Ambient declaration to allow references to `this.constructor` in class methods.\n\t *\n\t * @internal\n\t */\n\tconstructor: typeof Collection;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam Key - The key type this collection holds\n * @typeParam Value - The value type this collection holds\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class Collection<Key, Value> extends Map<Key, Value> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: Key[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: Key[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): Value | undefined;\n\tpublic first(amount: number): Value[];\n\tpublic first(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tif (amount >= this.size) return [...this.values()];\n\n\t\tconst iter = this.values();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Value[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): Key | undefined;\n\tpublic firstKey(amount: number): Key[];\n\tpublic firstKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tif (amount >= this.size) return [...this.keys()];\n\n\t\tconst iter = this.keys();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Key[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): Value | undefined;\n\tpublic last(amount: number): Value[];\n\tpublic last(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.first(amount * -1);\n\n\t\tconst arr = [...this.values()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): Key | undefined;\n\tpublic lastKey(amount: number): Key[];\n\tpublic lastKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number): Value | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.values();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number): Key | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.keys();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): Value | undefined;\n\tpublic random(amount: number): Value[];\n\tpublic random(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst values = [...this.values()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (values.length - sourceIndex));\n\t\t\t[values[sourceIndex], values[targetIndex]] = [values[targetIndex]!, values[sourceIndex]!];\n\t\t}\n\n\t\treturn values.slice(0, amount);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): Key | undefined;\n\tpublic randomKey(amount: number): Key[];\n\tpublic randomKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst keys = [...this.keys()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (keys.length - sourceIndex));\n\t\t\t[keys[sourceIndex], keys[targetIndex]] = [keys[targetIndex]!, keys[sourceIndex]!];\n\t\t}\n\n\t\treturn keys.slice(0, amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const [key, value] of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic find<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic find<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLast<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic findLast<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic findLast<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst val = entries[index]![1];\n\t\t\tconst key = entries[index]![0];\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLastKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findLastKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findLastKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst key = entries[index]![0];\n\t\t\tconst val = entries[index]![1];\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;\n\tpublic sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): Collection<NewKey, Value>;\n\tpublic filter<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): Collection<Key, NewValue>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;\n\tpublic filter<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): Collection<NewKey, Value>;\n\tpublic filter<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic filter<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Collection<Key, Value>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Collection<Key, Value> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<Key, Value>();\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) results.set(key, val);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<Key, Value>, Collection<Key, Value>] = [\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t];\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) {\n\t\t\t\tresults[0].set(key, val);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, val);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue, This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<Key, NewValue>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];\n\tpublic map<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): NewValue[];\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: NewValue[] = new Array(this.size);\n\t\tfor (let index = 0; index < this.size; index++) {\n\t\t\tconst [key, value] = iter.next().value!;\n\t\t\tresults[index] = fn(value, key, this);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;\n\tpublic mapValues<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic mapValues<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<Key, NewValue>();\n\t\tfor (const [key, val] of this) coll.set(key, fn(val, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): this is Collection<Key, NewValue>;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic every<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): this is Collection<Key, NewValue>;\n\tpublic every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (!fn(val, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: InitialValue;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value![1] as unknown as InitialValue;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const [key, value] of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t */\n\tpublic reduceRight(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tconst entries = [...this.entries()];\n\t\tlet accumulator!: InitialValue;\n\n\t\tlet index: number;\n\t\tif (initialValue === undefined) {\n\t\t\tif (entries.length === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = entries[entries.length - 1]![1] as unknown as InitialValue;\n\t\t\tindex = entries.length - 1;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t\tindex = entries.length;\n\t\t}\n\n\t\twhile (--index >= 0) {\n\t\t\tconst key = entries[index]![0];\n\t\t\tconst val = entries[index]![1];\n\t\t\taccumulator = fn(accumulator, val, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void): this;\n\tpublic each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const [key, value] of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<Key, Value>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const [key, val] of coll) newColl.set(key, val);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<Key, Value>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const [key, value] of this) {\n\t\t\tconst otherValue = collection.get(key);\n\t\t\t// If values differ, collections aren't equal.\n\t\t\t// For undefined values, we must also verify the key exists in the other collection,\n\t\t\t// since get() returns undefined for both missing keys and keys with undefined values.\n\t\t\tif (otherValue !== value || (otherValue === undefined && !collection.has(key))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<Key, Value> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const [key, value] of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersection method returns a new collection containing the items where the key is present in both collections.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const intersection = col1.intersection(col2);\n\t * console.log(col1.intersection(col2));\n\t * // => Collection { 'a' => 1 }\n\t * ```\n\t */\n\tpublic intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in either of the collections.\n\t *\n\t * @remarks\n\t *\n\t * If the collections have any items with the same key, the value from the first collection will be used.\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);\n\t * const union = col1.union(col2);\n\t * console.log(union);\n\t * // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>(this);\n\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!coll.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in this collection but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * console.log(col1.difference(col2));\n\t * // => Collection { 'b' => 2 }\n\t * console.log(col2.difference(col1));\n\t * // => Collection { 'c' => 3 }\n\t * ```\n\t */\n\tpublic difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing only the items where the keys are present in either collection, but not both.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const symmetricDifference = col1.symmetricDifference(col2);\n\t * console.log(col1.symmetricDifference(col2));\n\t * // => Collection { 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic symmetricDifference<OtherValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<OtherValue, ResultValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t\twhenInSelf: (value: Value, key: Key) => Keep<ResultValue>,\n\t\twhenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t\twhenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t): Collection<Key, ResultValue> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, ResultValue>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf) {\n\t\t\t\tif (hasInOther) {\n\t\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t} else {\n\t\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t}\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic toReversed() {\n\t\treturn new this.constructor[Symbol.species](this).reverse();\n\t}\n\n\t/**\n\t * The toSorted method returns a shallow copy of the collection with the items sorted.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * const sortedCollection = collection.toSorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic toSorted(compareFunction: Comparator<Key, Value> = Collection.defaultSort): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this).sort(compareFunction);\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.entries()];\n\t}\n\n\t/**\n\t * Emulates the default sort comparison algorithm used in ECMAScript. Equivalent to calling the\n\t * {@link https://tc39.es/ecma262/multipage/indexed-collections.html#sec-comparearrayelements | CompareArrayElements}\n\t * operation with arguments `firstValue`, `secondValue` and `undefined`.\n\t */\n\tprivate static defaultSort<Value>(firstValue: Value, secondValue: Value): number {\n\t\tif (firstValue === undefined) return secondValue === undefined ? 0 : 1;\n\t\tif (secondValue === undefined) return -1;\n\n\t\tconst x = String(firstValue);\n\t\tconst y = String(secondValue);\n\t\tif (x < y) return -1;\n\t\tif (y < x) return 1;\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<Key, Value>(\n\t\tentries: Iterable<[Key, Value]>,\n\t\tcombine: (firstValue: Value, secondValue: Value, key: Key) => Value,\n\t): Collection<Key, Value> {\n\t\tconst coll = new this[Symbol.species]<Key, Value>();\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()}\n\t * but returns a Collection instead of a Map.\n\t */\n\tpublic static override groupBy<Key, Item>(\n\t\titems: Iterable<Item>,\n\t\tkeySelector: (item: Item, index: number) => Key,\n\t): Collection<Key, Item[]> {\n\t\treturn new this[Symbol.species]<Key, Item[]>(Map.groupBy(items, keySelector));\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tdeclare public static readonly [Symbol.species]: typeof Collection;\n}\n\nexport type Keep<Value> = { keep: false } | { keep: true; value: Value };\n\nexport type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4BO,IAAM,aAAN,MAAM,oBAA+B,IAAgB;AAAA,EA5B5D,OA4B4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpD,OAAO,KAAU,uBAAqE;AAC5F,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO,KAAK,IAAI,GAAG;AACtC,QAAI,OAAO,0BAA0B,WAAY,OAAM,IAAI,UAAU,GAAG,qBAAqB,oBAAoB;AACjH,UAAM,eAAe,sBAAsB,KAAK,IAAI;AACpD,SAAK,IAAI,KA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KAAK,KAAK,KAAK,SAAS;AACnC,UAAI,KAAK,IAAI,GAAG,GAAG;AAClB,aAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAI,OAAO,GAAG,CAAC;AAAA,MAClD,OAAO;AACN,aAAK,IAAI,KAAK,KAAK;AAAA,MACpB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAuB,QACtB,OACA,aAC0B;AAC1B,WAAO,IAAI,KAAK,OAAO,OAAO,EAAe,IAAI,QAAQ,OAAO,WAAW,CAAC;AAAA,EAC7E;AAMD;;;AD/kCO,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/collection.ts"],"sourcesContent":["export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\nexport const version = '3.0.0-dev.1769083302-838cd2da3' as string;\n","/* eslint-disable no-param-reassign */\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<Key, Value> = Omit<\n\tCollection<Key, Value>,\n\tkeyof Map<Key, Value> | 'ensure' | 'reverse' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<Key, Value>;\n\nexport interface Collection<Key, Value> {\n\t/**\n\t * Ambient declaration to allow references to `this.constructor` in class methods.\n\t *\n\t * @internal\n\t */\n\tconstructor: typeof Collection;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam Key - The key type this collection holds\n * @typeParam Value - The value type this collection holds\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class Collection<Key, Value> extends Map<Key, Value> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: Key[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: Key[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): Value | undefined;\n\tpublic first(amount: number): Value[];\n\tpublic first(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tif (amount >= this.size) return [...this.values()];\n\n\t\tconst iter = this.values();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Value[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): Key | undefined;\n\tpublic firstKey(amount: number): Key[];\n\tpublic firstKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tif (amount >= this.size) return [...this.keys()];\n\n\t\tconst iter = this.keys();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Key[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): Value | undefined;\n\tpublic last(amount: number): Value[];\n\tpublic last(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.first(amount * -1);\n\n\t\tconst arr = [...this.values()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): Key | undefined;\n\tpublic lastKey(amount: number): Key[];\n\tpublic lastKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number): Value | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.values();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number): Key | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.keys();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): Value | undefined;\n\tpublic random(amount: number): Value[];\n\tpublic random(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst values = [...this.values()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (values.length - sourceIndex));\n\t\t\t[values[sourceIndex], values[targetIndex]] = [values[targetIndex]!, values[sourceIndex]!];\n\t\t}\n\n\t\treturn values.slice(0, amount);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): Key | undefined;\n\tpublic randomKey(amount: number): Key[];\n\tpublic randomKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst keys = [...this.keys()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (keys.length - sourceIndex));\n\t\t\t[keys[sourceIndex], keys[targetIndex]] = [keys[targetIndex]!, keys[sourceIndex]!];\n\t\t}\n\n\t\treturn keys.slice(0, amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const { 0: key, 1: value } of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic find<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic find<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return value;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLast<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic findLast<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic findLast<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\tif (fn(value, key, this)) return value;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLastKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findLastKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findLastKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\tif (fn(value, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;\n\tpublic sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): Collection<NewKey, Value>;\n\tpublic filter<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): Collection<Key, NewValue>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;\n\tpublic filter<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): Collection<NewKey, Value>;\n\tpublic filter<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic filter<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Collection<Key, Value>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Collection<Key, Value> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<Key, Value>();\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) results.set(key, value);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<Key, Value>, Collection<Key, Value>] = [\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t];\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) {\n\t\t\t\tresults[0].set(key, value);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue, This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<Key, NewValue>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];\n\tpublic map<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): NewValue[];\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: NewValue[] = new Array(this.size);\n\t\tfor (let index = 0; index < this.size; index++) {\n\t\t\tconst { 0: key, 1: value } = iter.next().value!;\n\t\t\tresults[index] = fn(value, key, this);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;\n\tpublic mapValues<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic mapValues<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<Key, NewValue>();\n\t\tfor (const { 0: key, 1: value } of this) coll.set(key, fn(value, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): this is Collection<Key, NewValue>;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic every<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): this is Collection<Key, NewValue>;\n\tpublic every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!fn(value, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: InitialValue;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value![1] as unknown as InitialValue;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const { 0: key, 1: value } of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t */\n\tpublic reduceRight(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tconst entries = [...this.entries()];\n\t\tlet accumulator!: InitialValue;\n\n\t\tlet index: number;\n\t\tif (initialValue === undefined) {\n\t\t\tif (entries.length === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = entries[entries.length - 1]![1] as unknown as InitialValue;\n\t\t\tindex = entries.length - 1;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t\tindex = entries.length;\n\t\t}\n\n\t\twhile (--index >= 0) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void): this;\n\tpublic each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<Key, Value>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const { 0: key, 1: value } of coll) newColl.set(key, value);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<Key, Value>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tconst otherValue = collection.get(key);\n\t\t\t// If values differ, collections aren't equal.\n\t\t\t// For undefined values, we must also verify the key exists in the other collection,\n\t\t\t// since get() returns undefined for both missing keys and keys with undefined values.\n\t\t\tif (otherValue !== value || (otherValue === undefined && !collection.has(key))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<Key, Value> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const { 0: key, 1: value } of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersection method returns a new collection containing the items where the key is present in both collections.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const intersection = col1.intersection(col2);\n\t * console.log(col1.intersection(col2));\n\t * // => Collection { 'a' => 1 }\n\t * ```\n\t */\n\tpublic intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in either of the collections.\n\t *\n\t * @remarks\n\t *\n\t * If the collections have any items with the same key, the value from the first collection will be used.\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);\n\t * const union = col1.union(col2);\n\t * console.log(union);\n\t * // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>(this);\n\n\t\tfor (const { 0: key, 1: value } of other) {\n\t\t\tif (!coll.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in this collection but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * console.log(col1.difference(col2));\n\t * // => Collection { 'b' => 2 }\n\t * console.log(col2.difference(col1));\n\t * // => Collection { 'c' => 3 }\n\t * ```\n\t */\n\tpublic difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing only the items where the keys are present in either collection, but not both.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const symmetricDifference = col1.symmetricDifference(col2);\n\t * console.log(col1.symmetricDifference(col2));\n\t * // => Collection { 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic symmetricDifference<OtherValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const { 0: key, 1: value } of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<OtherValue, ResultValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t\twhenInSelf: (value: Value, key: Key) => Keep<ResultValue>,\n\t\twhenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t\twhenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t): Collection<Key, ResultValue> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, ResultValue>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf) {\n\t\t\t\tif (hasInOther) {\n\t\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t} else {\n\t\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t}\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic toReversed() {\n\t\treturn new this.constructor[Symbol.species](this).reverse();\n\t}\n\n\t/**\n\t * The toSorted method returns a shallow copy of the collection with the items sorted.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * const sortedCollection = collection.toSorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic toSorted(compareFunction: Comparator<Key, Value> = Collection.defaultSort): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this).sort(compareFunction);\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.entries()];\n\t}\n\n\t/**\n\t * Emulates the default sort comparison algorithm used in ECMAScript. Equivalent to calling the\n\t * {@link https://tc39.es/ecma262/multipage/indexed-collections.html#sec-comparearrayelements | CompareArrayElements}\n\t * operation with arguments `firstValue`, `secondValue` and `undefined`.\n\t */\n\tprivate static defaultSort<Value>(firstValue: Value, secondValue: Value): number {\n\t\tif (firstValue === undefined) return secondValue === undefined ? 0 : 1;\n\t\tif (secondValue === undefined) return -1;\n\n\t\tconst x = String(firstValue);\n\t\tconst y = String(secondValue);\n\t\tif (x < y) return -1;\n\t\tif (y < x) return 1;\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<Key, Value>(\n\t\tentries: Iterable<[Key, Value]>,\n\t\tcombine: (firstValue: Value, secondValue: Value, key: Key) => Value,\n\t): Collection<Key, Value> {\n\t\tconst coll = new this[Symbol.species]<Key, Value>();\n\t\tfor (const { 0: key, 1: value } of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()}\n\t * but returns a Collection instead of a Map.\n\t */\n\tpublic static override groupBy<Key, Item>(\n\t\titems: Iterable<Item>,\n\t\tkeySelector: (item: Item, index: number) => Key,\n\t): Collection<Key, Item[]> {\n\t\treturn new this[Symbol.species]<Key, Item[]>(Map.groupBy(items, keySelector));\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tdeclare public static readonly [Symbol.species]: typeof Collection;\n}\n\nexport type Keep<Value> = { keep: false } | { keep: true; value: Value };\n\nexport type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4BO,IAAM,aAAN,MAAM,oBAA+B,IAAgB;AAAA,EA5B5D,OA4B4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpD,OAAO,KAAU,uBAAqE;AAC5F,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO,KAAK,IAAI,GAAG;AACtC,QAAI,OAAO,0BAA0B,WAAY,OAAM,IAAI,UAAU,GAAG,qBAAqB,oBAAoB;AACjH,UAAM,eAAe,sBAAsB,KAAK,IAAI;AACpD,SAAK,IAAI,KAAK,YAAY;AAC1B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,UAAU,MAAa;AAC7B,WAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,IAAI,GAAG,CAAC;AAAA,EAC1C;AAAA;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,MAAM,KAAK,SAAS;AAC3C,UAAI,KAAK,IAAI,GAAG,GAAG;AAClB,aAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAI,OAAO,GAAG,CAAC;AAAA,MAClD,OAAO;AACN,aAAK,IAAI,KAAK,KAAK;AAAA,MACpB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAuB,QACtB,OACA,aAC0B;AAC1B,WAAO,IAAI,KAAK,OAAO,OAAO,EAAe,IAAI,QAAQ,OAAO,WAAW,CAAC;AAAA,EAC7E;AAMD;;;AD5kCO,IAAM,UAAU;","names":[]}
package/dist/index.mjs CHANGED
@@ -148,22 +148,22 @@ var Collection = class _Collection extends Map {
148
148
  reverse() {
149
149
  const entries = [...this.entries()].reverse();
150
150
  this.clear();
151
- for (const [key, value] of entries) this.set(key, value);
151
+ for (const { 0: key, 1: value } of entries) this.set(key, value);
152
152
  return this;
153
153
  }
154
154
  find(fn, thisArg) {
155
155
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
156
156
  if (thisArg !== void 0) fn = fn.bind(thisArg);
157
- for (const [key, val] of this) {
158
- if (fn(val, key, this)) return val;
157
+ for (const { 0: key, 1: value } of this) {
158
+ if (fn(value, key, this)) return value;
159
159
  }
160
160
  return void 0;
161
161
  }
162
162
  findKey(fn, thisArg) {
163
163
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
164
164
  if (thisArg !== void 0) fn = fn.bind(thisArg);
165
- for (const [key, val] of this) {
166
- if (fn(val, key, this)) return key;
165
+ for (const { 0: key, 1: value } of this) {
166
+ if (fn(value, key, this)) return key;
167
167
  }
168
168
  return void 0;
169
169
  }
@@ -172,9 +172,8 @@ var Collection = class _Collection extends Map {
172
172
  if (thisArg !== void 0) fn = fn.bind(thisArg);
173
173
  const entries = [...this.entries()];
174
174
  for (let index = entries.length - 1; index >= 0; index--) {
175
- const val = entries[index][1];
176
- const key = entries[index][0];
177
- if (fn(val, key, this)) return val;
175
+ const { 0: key, 1: value } = entries[index];
176
+ if (fn(value, key, this)) return value;
178
177
  }
179
178
  return void 0;
180
179
  }
@@ -183,9 +182,8 @@ var Collection = class _Collection extends Map {
183
182
  if (thisArg !== void 0) fn = fn.bind(thisArg);
184
183
  const entries = [...this.entries()];
185
184
  for (let index = entries.length - 1; index >= 0; index--) {
186
- const key = entries[index][0];
187
- const val = entries[index][1];
188
- if (fn(val, key, this)) return key;
185
+ const { 0: key, 1: value } = entries[index];
186
+ if (fn(value, key, this)) return key;
189
187
  }
190
188
  return void 0;
191
189
  }
@@ -193,8 +191,8 @@ var Collection = class _Collection extends Map {
193
191
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
194
192
  if (thisArg !== void 0) fn = fn.bind(thisArg);
195
193
  const previousSize = this.size;
196
- for (const [key, val] of this) {
197
- if (fn(val, key, this)) this.delete(key);
194
+ for (const { 0: key, 1: value } of this) {
195
+ if (fn(value, key, this)) this.delete(key);
198
196
  }
199
197
  return previousSize - this.size;
200
198
  }
@@ -202,8 +200,8 @@ var Collection = class _Collection extends Map {
202
200
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
203
201
  if (thisArg !== void 0) fn = fn.bind(thisArg);
204
202
  const results = new this.constructor[Symbol.species]();
205
- for (const [key, val] of this) {
206
- if (fn(val, key, this)) results.set(key, val);
203
+ for (const { 0: key, 1: value } of this) {
204
+ if (fn(value, key, this)) results.set(key, value);
207
205
  }
208
206
  return results;
209
207
  }
@@ -214,11 +212,11 @@ var Collection = class _Collection extends Map {
214
212
  new this.constructor[Symbol.species](),
215
213
  new this.constructor[Symbol.species]()
216
214
  ];
217
- for (const [key, val] of this) {
218
- if (fn(val, key, this)) {
219
- results[0].set(key, val);
215
+ for (const { 0: key, 1: value } of this) {
216
+ if (fn(value, key, this)) {
217
+ results[0].set(key, value);
220
218
  } else {
221
- results[1].set(key, val);
219
+ results[1].set(key, value);
222
220
  }
223
221
  }
224
222
  return results;
@@ -233,7 +231,7 @@ var Collection = class _Collection extends Map {
233
231
  const iter = this.entries();
234
232
  const results = new Array(this.size);
235
233
  for (let index = 0; index < this.size; index++) {
236
- const [key, value] = iter.next().value;
234
+ const { 0: key, 1: value } = iter.next().value;
237
235
  results[index] = fn(value, key, this);
238
236
  }
239
237
  return results;
@@ -242,22 +240,22 @@ var Collection = class _Collection extends Map {
242
240
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
243
241
  if (thisArg !== void 0) fn = fn.bind(thisArg);
244
242
  const coll = new this.constructor[Symbol.species]();
245
- for (const [key, val] of this) coll.set(key, fn(val, key, this));
243
+ for (const { 0: key, 1: value } of this) coll.set(key, fn(value, key, this));
246
244
  return coll;
247
245
  }
248
246
  some(fn, thisArg) {
249
247
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
250
248
  if (thisArg !== void 0) fn = fn.bind(thisArg);
251
- for (const [key, val] of this) {
252
- if (fn(val, key, this)) return true;
249
+ for (const { 0: key, 1: value } of this) {
250
+ if (fn(value, key, this)) return true;
253
251
  }
254
252
  return false;
255
253
  }
256
254
  every(fn, thisArg) {
257
255
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
258
256
  if (thisArg !== void 0) fn = fn.bind(thisArg);
259
- for (const [key, val] of this) {
260
- if (!fn(val, key, this)) return false;
257
+ for (const { 0: key, 1: value } of this) {
258
+ if (!fn(value, key, this)) return false;
261
259
  }
262
260
  return true;
263
261
  }
@@ -271,7 +269,7 @@ var Collection = class _Collection extends Map {
271
269
  } else {
272
270
  accumulator = initialValue;
273
271
  }
274
- for (const [key, value] of iterator) {
272
+ for (const { 0: key, 1: value } of iterator) {
275
273
  accumulator = fn(accumulator, value, key, this);
276
274
  }
277
275
  return accumulator;
@@ -290,16 +288,15 @@ var Collection = class _Collection extends Map {
290
288
  index = entries.length;
291
289
  }
292
290
  while (--index >= 0) {
293
- const key = entries[index][0];
294
- const val = entries[index][1];
295
- accumulator = fn(accumulator, val, key, this);
291
+ const { 0: key, 1: value } = entries[index];
292
+ accumulator = fn(accumulator, value, key, this);
296
293
  }
297
294
  return accumulator;
298
295
  }
299
296
  each(fn, thisArg) {
300
297
  if (typeof fn !== "function") throw new TypeError(`${fn} is not a function`);
301
298
  if (thisArg !== void 0) fn = fn.bind(thisArg);
302
- for (const [key, value] of this) {
299
+ for (const { 0: key, 1: value } of this) {
303
300
  fn(value, key, this);
304
301
  }
305
302
  return this;
@@ -333,7 +330,7 @@ var Collection = class _Collection extends Map {
333
330
  concat(...collections) {
334
331
  const newColl = this.clone();
335
332
  for (const coll of collections) {
336
- for (const [key, val] of coll) newColl.set(key, val);
333
+ for (const { 0: key, 1: value } of coll) newColl.set(key, value);
337
334
  }
338
335
  return newColl;
339
336
  }
@@ -349,7 +346,7 @@ var Collection = class _Collection extends Map {
349
346
  if (!collection) return false;
350
347
  if (this === collection) return true;
351
348
  if (this.size !== collection.size) return false;
352
- for (const [key, value] of this) {
349
+ for (const { 0: key, 1: value } of this) {
353
350
  const otherValue = collection.get(key);
354
351
  if (otherValue !== value || otherValue === void 0 && !collection.has(key)) {
355
352
  return false;
@@ -373,7 +370,7 @@ var Collection = class _Collection extends Map {
373
370
  const entries = [...this.entries()];
374
371
  entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
375
372
  super.clear();
376
- for (const [key, value] of entries) {
373
+ for (const { 0: key, 1: value } of entries) {
377
374
  super.set(key, value);
378
375
  }
379
376
  return this;
@@ -393,7 +390,7 @@ var Collection = class _Collection extends Map {
393
390
  */
394
391
  intersection(other) {
395
392
  const coll = new this.constructor[Symbol.species]();
396
- for (const [key, value] of this) {
393
+ for (const { 0: key, 1: value } of this) {
397
394
  if (other.has(key)) coll.set(key, value);
398
395
  }
399
396
  return coll;
@@ -416,7 +413,7 @@ var Collection = class _Collection extends Map {
416
413
  */
417
414
  union(other) {
418
415
  const coll = new this.constructor[Symbol.species](this);
419
- for (const [key, value] of other) {
416
+ for (const { 0: key, 1: value } of other) {
420
417
  if (!coll.has(key)) coll.set(key, value);
421
418
  }
422
419
  return coll;
@@ -437,7 +434,7 @@ var Collection = class _Collection extends Map {
437
434
  */
438
435
  difference(other) {
439
436
  const coll = new this.constructor[Symbol.species]();
440
- for (const [key, value] of this) {
437
+ for (const { 0: key, 1: value } of this) {
441
438
  if (!other.has(key)) coll.set(key, value);
442
439
  }
443
440
  return coll;
@@ -457,10 +454,10 @@ var Collection = class _Collection extends Map {
457
454
  */
458
455
  symmetricDifference(other) {
459
456
  const coll = new this.constructor[Symbol.species]();
460
- for (const [key, value] of this) {
457
+ for (const { 0: key, 1: value } of this) {
461
458
  if (!other.has(key)) coll.set(key, value);
462
459
  }
463
- for (const [key, value] of other) {
460
+ for (const { 0: key, 1: value } of other) {
464
461
  if (!this.has(key)) coll.set(key, value);
465
462
  }
466
463
  return coll;
@@ -566,7 +563,7 @@ var Collection = class _Collection extends Map {
566
563
  */
567
564
  static combineEntries(entries, combine) {
568
565
  const coll = new this[Symbol.species]();
569
- for (const [key, value] of entries) {
566
+ for (const { 0: key, 1: value } of entries) {
570
567
  if (coll.has(key)) {
571
568
  coll.set(key, combine(coll.get(key), value, key));
572
569
  } else {
@@ -585,7 +582,7 @@ var Collection = class _Collection extends Map {
585
582
  };
586
583
 
587
584
  // src/index.ts
588
- var version = "3.0.0-dev.1768521706-3d7412221";
585
+ var version = "3.0.0-dev.1769083302-838cd2da3";
589
586
  export {
590
587
  Collection,
591
588
  version
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/collection.ts","../src/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<Key, Value> = Omit<\n\tCollection<Key, Value>,\n\tkeyof Map<Key, Value> | 'ensure' | 'reverse' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<Key, Value>;\n\nexport interface Collection<Key, Value> {\n\t/**\n\t * Ambient declaration to allow references to `this.constructor` in class methods.\n\t *\n\t * @internal\n\t */\n\tconstructor: typeof Collection;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam Key - The key type this collection holds\n * @typeParam Value - The value type this collection holds\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class Collection<Key, Value> extends Map<Key, Value> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: Key[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: Key[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): Value | undefined;\n\tpublic first(amount: number): Value[];\n\tpublic first(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tif (amount >= this.size) return [...this.values()];\n\n\t\tconst iter = this.values();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Value[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): Key | undefined;\n\tpublic firstKey(amount: number): Key[];\n\tpublic firstKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tif (amount >= this.size) return [...this.keys()];\n\n\t\tconst iter = this.keys();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Key[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): Value | undefined;\n\tpublic last(amount: number): Value[];\n\tpublic last(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.first(amount * -1);\n\n\t\tconst arr = [...this.values()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): Key | undefined;\n\tpublic lastKey(amount: number): Key[];\n\tpublic lastKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number): Value | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.values();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number): Key | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.keys();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): Value | undefined;\n\tpublic random(amount: number): Value[];\n\tpublic random(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst values = [...this.values()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (values.length - sourceIndex));\n\t\t\t[values[sourceIndex], values[targetIndex]] = [values[targetIndex]!, values[sourceIndex]!];\n\t\t}\n\n\t\treturn values.slice(0, amount);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): Key | undefined;\n\tpublic randomKey(amount: number): Key[];\n\tpublic randomKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst keys = [...this.keys()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (keys.length - sourceIndex));\n\t\t\t[keys[sourceIndex], keys[targetIndex]] = [keys[targetIndex]!, keys[sourceIndex]!];\n\t\t}\n\n\t\treturn keys.slice(0, amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const [key, value] of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic find<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic find<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLast<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic findLast<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic findLast<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst val = entries[index]![1];\n\t\t\tconst key = entries[index]![0];\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLastKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findLastKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findLastKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst key = entries[index]![0];\n\t\t\tconst val = entries[index]![1];\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;\n\tpublic sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): Collection<NewKey, Value>;\n\tpublic filter<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): Collection<Key, NewValue>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;\n\tpublic filter<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): Collection<NewKey, Value>;\n\tpublic filter<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic filter<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Collection<Key, Value>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Collection<Key, Value> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<Key, Value>();\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) results.set(key, val);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<Key, Value>, Collection<Key, Value>] = [\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t];\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) {\n\t\t\t\tresults[0].set(key, val);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, val);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue, This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<Key, NewValue>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];\n\tpublic map<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): NewValue[];\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: NewValue[] = new Array(this.size);\n\t\tfor (let index = 0; index < this.size; index++) {\n\t\t\tconst [key, value] = iter.next().value!;\n\t\t\tresults[index] = fn(value, key, this);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;\n\tpublic mapValues<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic mapValues<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<Key, NewValue>();\n\t\tfor (const [key, val] of this) coll.set(key, fn(val, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): this is Collection<Key, NewValue>;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic every<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): this is Collection<Key, NewValue>;\n\tpublic every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (!fn(val, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: InitialValue;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value![1] as unknown as InitialValue;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const [key, value] of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t */\n\tpublic reduceRight(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tconst entries = [...this.entries()];\n\t\tlet accumulator!: InitialValue;\n\n\t\tlet index: number;\n\t\tif (initialValue === undefined) {\n\t\t\tif (entries.length === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = entries[entries.length - 1]![1] as unknown as InitialValue;\n\t\t\tindex = entries.length - 1;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t\tindex = entries.length;\n\t\t}\n\n\t\twhile (--index >= 0) {\n\t\t\tconst key = entries[index]![0];\n\t\t\tconst val = entries[index]![1];\n\t\t\taccumulator = fn(accumulator, val, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void): this;\n\tpublic each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const [key, value] of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<Key, Value>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const [key, val] of coll) newColl.set(key, val);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<Key, Value>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const [key, value] of this) {\n\t\t\tconst otherValue = collection.get(key);\n\t\t\t// If values differ, collections aren't equal.\n\t\t\t// For undefined values, we must also verify the key exists in the other collection,\n\t\t\t// since get() returns undefined for both missing keys and keys with undefined values.\n\t\t\tif (otherValue !== value || (otherValue === undefined && !collection.has(key))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<Key, Value> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const [key, value] of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersection method returns a new collection containing the items where the key is present in both collections.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const intersection = col1.intersection(col2);\n\t * console.log(col1.intersection(col2));\n\t * // => Collection { 'a' => 1 }\n\t * ```\n\t */\n\tpublic intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in either of the collections.\n\t *\n\t * @remarks\n\t *\n\t * If the collections have any items with the same key, the value from the first collection will be used.\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);\n\t * const union = col1.union(col2);\n\t * console.log(union);\n\t * // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>(this);\n\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!coll.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in this collection but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * console.log(col1.difference(col2));\n\t * // => Collection { 'b' => 2 }\n\t * console.log(col2.difference(col1));\n\t * // => Collection { 'c' => 3 }\n\t * ```\n\t */\n\tpublic difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing only the items where the keys are present in either collection, but not both.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const symmetricDifference = col1.symmetricDifference(col2);\n\t * console.log(col1.symmetricDifference(col2));\n\t * // => Collection { 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic symmetricDifference<OtherValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>();\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<OtherValue, ResultValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t\twhenInSelf: (value: Value, key: Key) => Keep<ResultValue>,\n\t\twhenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t\twhenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t): Collection<Key, ResultValue> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, ResultValue>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf) {\n\t\t\t\tif (hasInOther) {\n\t\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t} else {\n\t\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t}\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic toReversed() {\n\t\treturn new this.constructor[Symbol.species](this).reverse();\n\t}\n\n\t/**\n\t * The toSorted method returns a shallow copy of the collection with the items sorted.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * const sortedCollection = collection.toSorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic toSorted(compareFunction: Comparator<Key, Value> = Collection.defaultSort): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this).sort(compareFunction);\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.entries()];\n\t}\n\n\t/**\n\t * Emulates the default sort comparison algorithm used in ECMAScript. Equivalent to calling the\n\t * {@link https://tc39.es/ecma262/multipage/indexed-collections.html#sec-comparearrayelements | CompareArrayElements}\n\t * operation with arguments `firstValue`, `secondValue` and `undefined`.\n\t */\n\tprivate static defaultSort<Value>(firstValue: Value, secondValue: Value): number {\n\t\tif (firstValue === undefined) return secondValue === undefined ? 0 : 1;\n\t\tif (secondValue === undefined) return -1;\n\n\t\tconst x = String(firstValue);\n\t\tconst y = String(secondValue);\n\t\tif (x < y) return -1;\n\t\tif (y < x) return 1;\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<Key, Value>(\n\t\tentries: Iterable<[Key, Value]>,\n\t\tcombine: (firstValue: Value, secondValue: Value, key: Key) => Value,\n\t): Collection<Key, Value> {\n\t\tconst coll = new this[Symbol.species]<Key, Value>();\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()}\n\t * but returns a Collection instead of a Map.\n\t */\n\tpublic static override groupBy<Key, Item>(\n\t\titems: Iterable<Item>,\n\t\tkeySelector: (item: Item, index: number) => Key,\n\t): Collection<Key, Item[]> {\n\t\treturn new this[Symbol.species]<Key, Item[]>(Map.groupBy(items, keySelector));\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tdeclare public static readonly [Symbol.species]: typeof Collection;\n}\n\nexport type Keep<Value> = { keep: false } | { keep: true; value: Value };\n\nexport type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;\n","export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\nexport const version = '3.0.0-dev.1768521706-3d7412221' as string;\n"],"mappings":";;;;AA4BO,IAAM,aAAN,MAAM,oBAA+B,IAAgB;AAAA,EA5B5D,OA4B4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpD,OAAO,KAAU,uBAAqE;AAC5F,QAAI,KAAK,IAAI,GAAG,EAAG,QA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,OAAc,eACb,SACA,SACyB;AACzB,UAAM,OAAO,IAAI,KAAK,OAAO,OAAO,EAAc;AAClD,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AACnC,UAAI,KAAK,IAAI,GAAG,GAAG;AAClB,aAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAI,OAAO,GAAG,CAAC;AAAA,MAClD,OAAO;AACN,aAAK,IAAI,KAAK,KAAK;AAAA,MACpB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAuB,QACtB,OACA,aAC0B;AAC1B,WAAO,IAAI,KAAK,OAAO,OAAO,EAAe,IAAI,QAAQ,OAAO,WAAW,CAAC;AAAA,EAC7E;AAMD;;;AC/kCO,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/collection.ts","../src/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<Key, Value> = Omit<\n\tCollection<Key, Value>,\n\tkeyof Map<Key, Value> | 'ensure' | 'reverse' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<Key, Value>;\n\nexport interface Collection<Key, Value> {\n\t/**\n\t * Ambient declaration to allow references to `this.constructor` in class methods.\n\t *\n\t * @internal\n\t */\n\tconstructor: typeof Collection;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam Key - The key type this collection holds\n * @typeParam Value - The value type this collection holds\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class Collection<Key, Value> extends Map<Key, Value> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: Key, defaultValueGenerator: (key: Key, collection: this) => Value): Value {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: Key[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: Key[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): Value | undefined;\n\tpublic first(amount: number): Value[];\n\tpublic first(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tif (amount >= this.size) return [...this.values()];\n\n\t\tconst iter = this.values();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Value[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): Key | undefined;\n\tpublic firstKey(amount: number): Key[];\n\tpublic firstKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tif (amount >= this.size) return [...this.keys()];\n\n\t\tconst iter = this.keys();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: Key[] = new Array(amount);\n\t\tfor (let index = 0; index < amount; index++) {\n\t\t\tresults[index] = iter.next().value!;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): Value | undefined;\n\tpublic last(amount: number): Value[];\n\tpublic last(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.first(amount * -1);\n\n\t\tconst arr = [...this.values()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): Key | undefined;\n\tpublic lastKey(amount: number): Key[];\n\tpublic lastKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(-1);\n\t\tif (!amount) return [];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.slice(amount * -1);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number): Value | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.values();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number): Key | undefined {\n\t\tindex = Math.trunc(index);\n\t\tif (index >= 0) {\n\t\t\tif (index >= this.size) return undefined;\n\t\t} else {\n\t\t\tindex += this.size;\n\t\t\tif (index < 0) return undefined;\n\t\t}\n\n\t\tconst iter = this.keys();\n\t\tfor (let skip = 0; skip < index; skip++) {\n\t\t\titer.next();\n\t\t}\n\n\t\treturn iter.next().value!;\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): Value | undefined;\n\tpublic random(amount: number): Value[];\n\tpublic random(amount?: number): Value | Value[] | undefined {\n\t\tif (amount === undefined) return this.at(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst values = [...this.values()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (values.length - sourceIndex));\n\t\t\t[values[sourceIndex], values[targetIndex]] = [values[targetIndex]!, values[sourceIndex]!];\n\t\t}\n\n\t\treturn values.slice(0, amount);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): Key | undefined;\n\tpublic randomKey(amount: number): Key[];\n\tpublic randomKey(amount?: number): Key | Key[] | undefined {\n\t\tif (amount === undefined) return this.keyAt(Math.floor(Math.random() * this.size));\n\t\tamount = Math.min(this.size, amount);\n\t\tif (!amount) return [];\n\n\t\tconst keys = [...this.keys()];\n\t\tfor (let sourceIndex = 0; sourceIndex < amount; sourceIndex++) {\n\t\t\tconst targetIndex = sourceIndex + Math.floor(Math.random() * (keys.length - sourceIndex));\n\t\t\t[keys[sourceIndex], keys[targetIndex]] = [keys[targetIndex]!, keys[sourceIndex]!];\n\t\t}\n\n\t\treturn keys.slice(0, amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const { 0: key, 1: value } of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic find<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic find<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic find(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return value;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast | Array.findLast()}.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLast<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): NewValue | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown): Value | undefined;\n\tpublic findLast<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): NewValue | undefined;\n\tpublic findLast<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Value | undefined;\n\tpublic findLast(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Value | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\tif (fn(value, key, this)) return value;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a last item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex | Array.findLastIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t */\n\tpublic findLastKey<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): NewKey | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown): Key | undefined;\n\tpublic findLastKey<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): NewKey | undefined;\n\tpublic findLastKey<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Key | undefined;\n\tpublic findLastKey(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Key | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst entries = [...this.entries()];\n\t\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\tif (fn(value, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown): number;\n\tpublic sweep<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): number;\n\tpublic sweep(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): Collection<NewKey, Value>;\n\tpublic filter<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): Collection<Key, NewValue>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown): Collection<Key, Value>;\n\tpublic filter<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): Collection<NewKey, Value>;\n\tpublic filter<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic filter<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): Collection<Key, Value>;\n\tpublic filter(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): Collection<Key, Value> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<Key, Value>();\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) results.set(key, value);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): [Collection<NewKey, Value>, Collection<Exclude<Key, NewKey>, Value>];\n\tpublic partition<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): [Collection<Key, NewValue>, Collection<Key, Exclude<Value, NewValue>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<Key, Value>, Collection<Key, Value>];\n\tpublic partition(\n\t\tfn: (value: Value, key: Key, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<Key, Value>, Collection<Key, Value>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<Key, Value>, Collection<Key, Value>] = [\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t\tnew this.constructor[Symbol.species]<Key, Value>(),\n\t\t];\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) {\n\t\t\t\tresults[0].set(key, value);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue, This>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic flatMap<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => Collection<Key, NewValue>,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<Key, NewValue>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): NewValue[];\n\tpublic map<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): NewValue[];\n\tpublic map<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue, thisArg?: unknown): NewValue[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\t// eslint-disable-next-line unicorn/no-new-array\n\t\tconst results: NewValue[] = new Array(this.size);\n\t\tfor (let index = 0; index < this.size; index++) {\n\t\t\tconst { 0: key, 1: value } = iter.next().value!;\n\t\t\tresults[index] = fn(value, key, this);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<NewValue>(fn: (value: Value, key: Key, collection: this) => NewValue): Collection<Key, NewValue>;\n\tpublic mapValues<This, NewValue>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg: This,\n\t): Collection<Key, NewValue>;\n\tpublic mapValues<NewValue>(\n\t\tfn: (value: Value, key: Key, collection: this) => NewValue,\n\t\tthisArg?: unknown,\n\t): Collection<Key, NewValue> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<Key, NewValue>();\n\t\tfor (const { 0: key, 1: value } of this) coll.set(key, fn(value, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic some<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic some(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (fn(value, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<NewKey extends Key>(\n\t\tfn: (value: Value, key: Key, collection: this) => key is NewKey,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<NewValue extends Value>(\n\t\tfn: (value: Value, key: Key, collection: this) => value is NewValue,\n\t): this is Collection<Key, NewValue>;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown): boolean;\n\tpublic every<This, NewKey extends Key>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => key is NewKey,\n\t\tthisArg: This,\n\t): this is Collection<NewKey, Value>;\n\tpublic every<This, NewValue extends Value>(\n\t\tfn: (this: This, value: Value, key: Key, collection: this) => value is NewValue,\n\t\tthisArg: This,\n\t): this is Collection<Key, NewValue>;\n\tpublic every<This>(fn: (this: This, value: Value, key: Key, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: Value, key: Key, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!fn(value, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduce<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: InitialValue;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value![1] as unknown as InitialValue;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const { 0: key, 1: value } of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight | Array.reduceRight()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `value`, `key`, and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t */\n\tpublic reduceRight(\n\t\tfn: (accumulator: Value, value: Value, key: Key, collection: this) => Value,\n\t\tinitialValue?: Value,\n\t): Value;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue: InitialValue,\n\t): InitialValue;\n\tpublic reduceRight<InitialValue>(\n\t\tfn: (accumulator: InitialValue, value: Value, key: Key, collection: this) => InitialValue,\n\t\tinitialValue?: InitialValue,\n\t): InitialValue {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tconst entries = [...this.entries()];\n\t\tlet accumulator!: InitialValue;\n\n\t\tlet index: number;\n\t\tif (initialValue === undefined) {\n\t\t\tif (entries.length === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = entries[entries.length - 1]![1] as unknown as InitialValue;\n\t\t\tindex = entries.length - 1;\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t\tindex = entries.length;\n\t\t}\n\n\t\twhile (--index >= 0) {\n\t\t\tconst { 0: key, 1: value } = entries[index]!;\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void): this;\n\tpublic each<This>(fn: (this: This, value: Value, key: Key, collection: this) => void, thisArg: This): this;\n\tpublic each(fn: (value: Value, key: Key, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing the function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<This>(fn: (this: This, collection: this) => void, thisArg: This): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<Key, Value>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const { 0: key, 1: value } of coll) newColl.set(key, value);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<Key, Value>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tconst otherValue = collection.get(key);\n\t\t\t// If values differ, collections aren't equal.\n\t\t\t// For undefined values, we must also verify the key exists in the other collection,\n\t\t\t// since get() returns undefined for both missing keys and keys with undefined values.\n\t\t\tif (otherValue !== value || (otherValue === undefined && !collection.has(key))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<Key, Value> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const { 0: key, 1: value } of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersection method returns a new collection containing the items where the key is present in both collections.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const intersection = col1.intersection(col2);\n\t * console.log(col1.intersection(col2));\n\t * // => Collection { 'a' => 1 }\n\t * ```\n\t */\n\tpublic intersection(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in either of the collections.\n\t *\n\t * @remarks\n\t *\n\t * If the collections have any items with the same key, the value from the first collection will be used.\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['b', 3], ['c', 3]]);\n\t * const union = col1.union(col2);\n\t * console.log(union);\n\t * // => Collection { 'a' => 1, 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic union<OtherValue>(other: ReadonlyCollection<Key, OtherValue>): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>(this);\n\n\t\tfor (const { 0: key, 1: value } of other) {\n\t\t\tif (!coll.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing the items where the key is present in this collection but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * console.log(col1.difference(col2));\n\t * // => Collection { 'b' => 2 }\n\t * console.log(col2.difference(col1));\n\t * // => Collection { 'c' => 3 }\n\t * ```\n\t */\n\tpublic difference(other: ReadonlyCollection<Key, any>): Collection<Key, Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Returns a new collection containing only the items where the keys are present in either collection, but not both.\n\t *\n\t * @param other - The other Collection to filter against\n\t * @example\n\t * ```ts\n\t * const col1 = new Collection([['a', 1], ['b', 2]]);\n\t * const col2 = new Collection([['a', 1], ['c', 3]]);\n\t * const symmetricDifference = col1.symmetricDifference(col2);\n\t * console.log(col1.symmetricDifference(col2));\n\t * // => Collection { 'b' => 2, 'c' => 3 }\n\t * ```\n\t */\n\tpublic symmetricDifference<OtherValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t): Collection<Key, OtherValue | Value> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, OtherValue | Value>();\n\n\t\tfor (const { 0: key, 1: value } of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const { 0: key, 1: value } of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<OtherValue, ResultValue>(\n\t\tother: ReadonlyCollection<Key, OtherValue>,\n\t\twhenInSelf: (value: Value, key: Key) => Keep<ResultValue>,\n\t\twhenInOther: (valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t\twhenInBoth: (value: Value, valueOther: OtherValue, key: Key) => Keep<ResultValue>,\n\t): Collection<Key, ResultValue> {\n\t\tconst coll = new this.constructor[Symbol.species]<Key, ResultValue>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf) {\n\t\t\t\tif (hasInOther) {\n\t\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t} else {\n\t\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t\t}\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toReversed | Array.toReversed()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic toReversed() {\n\t\treturn new this.constructor[Symbol.species](this).reverse();\n\t}\n\n\t/**\n\t * The toSorted method returns a shallow copy of the collection with the items sorted.\n\t * If a comparison function is not provided, the function sorts by element values, using the same stringwise comparison algorithm as\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | Array.sort()}.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order. The return value of this function should be negative if\n\t * `a` comes before `b`, positive if `b` comes before `a`, or zero if `a` and `b` are considered equal.\n\t * @example\n\t * ```ts\n\t * const sortedCollection = collection.toSorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic toSorted(compareFunction: Comparator<Key, Value> = Collection.defaultSort): Collection<Key, Value> {\n\t\treturn new this.constructor[Symbol.species](this).sort(compareFunction);\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.entries()];\n\t}\n\n\t/**\n\t * Emulates the default sort comparison algorithm used in ECMAScript. Equivalent to calling the\n\t * {@link https://tc39.es/ecma262/multipage/indexed-collections.html#sec-comparearrayelements | CompareArrayElements}\n\t * operation with arguments `firstValue`, `secondValue` and `undefined`.\n\t */\n\tprivate static defaultSort<Value>(firstValue: Value, secondValue: Value): number {\n\t\tif (firstValue === undefined) return secondValue === undefined ? 0 : 1;\n\t\tif (secondValue === undefined) return -1;\n\n\t\tconst x = String(firstValue);\n\t\tconst y = String(secondValue);\n\t\tif (x < y) return -1;\n\t\tif (y < x) return 1;\n\t\treturn 0;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<Key, Value>(\n\t\tentries: Iterable<[Key, Value]>,\n\t\tcombine: (firstValue: Value, secondValue: Value, key: Key) => Value,\n\t): Collection<Key, Value> {\n\t\tconst coll = new this[Symbol.species]<Key, Value>();\n\t\tfor (const { 0: key, 1: value } of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy | Map.groupBy()}\n\t * but returns a Collection instead of a Map.\n\t */\n\tpublic static override groupBy<Key, Item>(\n\t\titems: Iterable<Item>,\n\t\tkeySelector: (item: Item, index: number) => Key,\n\t): Collection<Key, Item[]> {\n\t\treturn new this[Symbol.species]<Key, Item[]>(Map.groupBy(items, keySelector));\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tdeclare public static readonly [Symbol.species]: typeof Collection;\n}\n\nexport type Keep<Value> = { keep: false } | { keep: true; value: Value };\n\nexport type Comparator<Key, Value> = (firstValue: Value, secondValue: Value, firstKey: Key, secondKey: Key) => number;\n","export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\nexport const version = '3.0.0-dev.1769083302-838cd2da3' as string;\n"],"mappings":";;;;AA4BO,IAAM,aAAN,MAAM,oBAA+B,IAAgB;AAAA,EA5B5D,OA4B4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpD,OAAO,KAAU,uBAAqE;AAC5F,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO,KAAK,IAAI,GAAG;AACtC,QAAI,OAAO,0BAA0B,WAAY,OAAM,IAAI,UAAU,GAAG,qBAAqB,oBAAoB;AACjH,UAAM,eAAe,sBAAsB,KAAK,IAAI;AACpD,SAAK,IAAI,KAAK,YAAY;AAC1B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO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,SACA,SACyB;AACzB,UAAM,OAAO,IAAI,KAAK,OAAO,OAAO,EAAc;AAClD,eAAW,EAAE,GAAG,KAAK,GAAG,MAAM,KAAK,SAAS;AAC3C,UAAI,KAAK,IAAI,GAAG,GAAG;AAClB,aAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAI,OAAO,GAAG,CAAC;AAAA,MAClD,OAAO;AACN,aAAK,IAAI,KAAK,KAAK;AAAA,MACpB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAuB,QACtB,OACA,aAC0B;AAC1B,WAAO,IAAI,KAAK,OAAO,OAAO,EAAe,IAAI,QAAQ,OAAO,WAAW,CAAC;AAAA,EAC7E;AAMD;;;AC5kCO,IAAM,UAAU;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@discordjs/collection",
4
- "version": "3.0.0-dev.1768521706-3d7412221",
4
+ "version": "3.0.0-dev.1769083302-838cd2da3",
5
5
  "description": "Utility data structure used in discord.js",
6
6
  "exports": {
7
7
  ".": {