mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Add Collection.concat
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -248,6 +248,21 @@ class Collection extends Map {
|
|||||||
return currentVal;
|
return currentVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||||
|
* @param {Collection} collections Collections to merge
|
||||||
|
* @returns {Collection}
|
||||||
|
* @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||||
|
*/
|
||||||
|
concat(...collections) {
|
||||||
|
const newColl = new this.constructor();
|
||||||
|
for (const [key, val] of this) newColl.set(key, val);
|
||||||
|
for (const coll of collections) {
|
||||||
|
for (const [key, val] of coll) newColl.set(key, val);
|
||||||
|
}
|
||||||
|
return newColl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the items in this collection have a delete method (e.g. messages), invoke
|
* If the items in this collection have a delete method (e.g. messages), invoke
|
||||||
* the delete method. Returns an array of promises
|
* the delete method. Returns an array of promises
|
||||||
|
|||||||
Reference in New Issue
Block a user