mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
Collection debug methods, remove deleteAll (#2577)
This commit is contained in:
parent
55863efa15
commit
8e0ea9aa16
1 changed files with 20 additions and 15 deletions
|
|
@ -333,12 +333,29 @@ class Collection extends Map {
|
|||
* @returns {Collection}
|
||||
* @example
|
||||
* collection
|
||||
* .tap(user => console.log(user.username))
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(user => console.log(user.username));
|
||||
* .each(user => console.log(user.username));
|
||||
*/
|
||||
each(fn, thisArg) {
|
||||
this.forEach(fn, thisArg);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
* @param {Function} fn Function to execute
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example
|
||||
* collection
|
||||
* .tap(coll => coll.size)
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => coll.size)
|
||||
*/
|
||||
tap(fn, thisArg) {
|
||||
this.forEach(fn, thisArg);
|
||||
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
||||
fn(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -365,18 +382,6 @@ class Collection extends Map {
|
|||
return newColl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the `delete()` method on all items that have it.
|
||||
* @returns {Promise[]}
|
||||
*/
|
||||
deleteAll() {
|
||||
const returns = [];
|
||||
for (const item of this.values()) {
|
||||
if (item.delete) returns.push(item.delete());
|
||||
}
|
||||
return returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this collection shares identical key-value pairings with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
|
|
|
|||
Loading…
Reference in a new issue