mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(BitField): use only enum names in iterating (#9357)
* fix: use only names in iterating bitfield * fix: not a number Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> * fix: serialize Co-authored-by: SpaceEEC <spaceeec@yahoo.com> --------- Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -117,7 +117,9 @@ class BitField {
|
||||
*/
|
||||
serialize(...hasParams) {
|
||||
const serialized = {};
|
||||
for (const [flag, bit] of Object.entries(this.constructor.Flags)) serialized[flag] = this.has(bit, ...hasParams);
|
||||
for (const [flag, bit] of Object.entries(this.constructor.Flags)) {
|
||||
if (isNaN(flag)) serialized[flag] = this.has(bit, ...hasParams);
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@@ -140,7 +142,7 @@ class BitField {
|
||||
|
||||
*[Symbol.iterator](...hasParams) {
|
||||
for (const bitName of Object.keys(this.constructor.Flags)) {
|
||||
if (this.has(bitName, ...hasParams)) yield bitName;
|
||||
if (isNaN(bitName) && this.has(bitName, ...hasParams)) yield bitName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user