Skip to content

Commit

Permalink
fix(BitField): use only enum names in iterating (#9357)
Browse files Browse the repository at this point in the history
* fix: use only names in iterating bitfield

* fix: not a number

Co-authored-by: Vlad Frangu <[email protected]>

* fix: serialize

Co-authored-by: SpaceEEC <[email protected]>

---------

Co-authored-by: Vlad Frangu <[email protected]>
Co-authored-by: SpaceEEC <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 28, 2023
1 parent 1b15d31 commit 40d07fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/discord.js/src/util/BitField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}

Expand Down

0 comments on commit 40d07fb

Please sign in to comment.