mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat: return entries instead of values in toJSON method (#9345)
* feat(collection): return entries instead of values in toJSON method * test: adjust test --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -828,9 +828,14 @@ describe('tap() tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('toJSON() tests', () => {
|
describe('toJSON() tests', () => {
|
||||||
test('it returns the values as an array', () => {
|
test('it returns the entries of the collection', () => {
|
||||||
const c = createTestCollection();
|
const c = createTestCollection();
|
||||||
expect(c.toJSON()).toStrictEqual([1, 2, 3]);
|
|
||||||
|
expect(c.toJSON()).toStrictEqual([
|
||||||
|
['a', 1],
|
||||||
|
['b', 2],
|
||||||
|
['c', 3],
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -933,7 +933,7 @@ export class Collection<K, V> extends Map<K, V> {
|
|||||||
|
|
||||||
public toJSON() {
|
public toJSON() {
|
||||||
// toJSON is called recursively by JSON.stringify.
|
// toJSON is called recursively by JSON.stringify.
|
||||||
return [...this.values()];
|
return [...this.entries()];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static defaultSort<V>(firstValue: V, secondValue: V): number {
|
private static defaultSort<V>(firstValue: V, secondValue: V): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user