mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 04:44:44 +12: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:
parent
67a2538b4d
commit
defeee5eec
2 changed files with 8 additions and 3 deletions
|
@ -828,9 +828,14 @@ describe('tap() tests', () => {
|
|||
});
|
||||
|
||||
describe('toJSON() tests', () => {
|
||||
test('it returns the values as an array', () => {
|
||||
test('it returns the entries of the collection', () => {
|
||||
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() {
|
||||
// toJSON is called recursively by JSON.stringify.
|
||||
return [...this.values()];
|
||||
return [...this.entries()];
|
||||
}
|
||||
|
||||
private static defaultSort<V>(firstValue: V, secondValue: V): number {
|
||||
|
|
Loading…
Reference in a new issue