mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 16:52:16 +00:00
Add Collection.concat
This commit is contained in:
parent
aed75e1f9a
commit
0bcca7bb55
2 changed files with 16 additions and 1 deletions
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue