mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 01:01:30 +00:00
Revert "fix(Collection): use new this.constructor instead of new Collection (#2709)"
This reverts commit c10b4feeeb.
This commit is contained in:
parent
382afee436
commit
98dc2df6d4
1 changed files with 3 additions and 3 deletions
|
|
@ -220,7 +220,7 @@ class Collection extends Map {
|
||||||
*/
|
*/
|
||||||
filter(fn, thisArg) {
|
filter(fn, thisArg) {
|
||||||
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
||||||
const results = new this.constructor();
|
const results = new Collection();
|
||||||
for (const [key, val] of this) {
|
for (const [key, val] of this) {
|
||||||
if (fn(val, key, this)) results.set(key, val);
|
if (fn(val, key, this)) results.set(key, val);
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ class Collection extends Map {
|
||||||
*/
|
*/
|
||||||
partition(fn, thisArg) {
|
partition(fn, thisArg) {
|
||||||
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
||||||
const results = [new this.constructor(), new this.constructor()];
|
const results = [new Collection(), new Collection()];
|
||||||
for (const [key, val] of this) {
|
for (const [key, val] of this) {
|
||||||
if (fn(val, key, this)) {
|
if (fn(val, key, this)) {
|
||||||
results[0].set(key, val);
|
results[0].set(key, val);
|
||||||
|
|
@ -404,7 +404,7 @@ class Collection extends Map {
|
||||||
* @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
* @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||||
*/
|
*/
|
||||||
sort(compareFunction = (x, y) => +(x > y) || +(x === y) - 1) {
|
sort(compareFunction = (x, y) => +(x > y) || +(x === y) - 1) {
|
||||||
return new this.constructor([...this.entries()].sort((a, b) => compareFunction(a[1], b[1], a[0], b[0])));
|
return new Collection([...this.entries()].sort((a, b) => compareFunction(a[1], b[1], a[0], b[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue