Skip to content

Commit

Permalink
ditto
Browse files Browse the repository at this point in the history
  • Loading branch information
MierenManz committed Jan 9, 2024
1 parent 79cc0a9 commit cb0201e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/bitflags/bitflags16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export class BitFlags16<
I extends Record<string, number>,
O = OutputRecord<I>,
> extends SizedType<O> {
#record: I;
#recordEntries: Array<[string, number]>;

constructor(record: I) {
super(2, 2);
this.#record = record;
this.#recordEntries = Object.entries(record);
}

readPacked(dt: DataView, options: Options = { byteOffset: 0 }): O {
Expand All @@ -18,7 +18,7 @@ export class BitFlags16<
const returnObject: Record<string, boolean> = {};

const byteBag = dt.getUint16(options.byteOffset);
for (const { 0: key, 1: flag } of Object.entries(this.#record)) {
for (const { 0: key, 1: flag } of this.#recordEntries) {
returnObject[key] = (byteBag & flag) === flag;
}

Expand All @@ -36,7 +36,7 @@ export class BitFlags16<

let flags = 0;

for (const { 0: key, 1: flagValue } of Object.entries(this.#record)) {
for (const { 0: key, 1: flagValue } of this.#recordEntries) {
if (value[key as keyof O]) {
flags |= flagValue;
}
Expand Down

0 comments on commit cb0201e

Please sign in to comment.