Skip to content

Commit

Permalink
Smaller code
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderOMara committed Nov 17, 2024
1 parent 1679cc5 commit 7c55baa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions i24.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,18 @@ export function setUint24(
value: number,
littleEndian = false,
): void {
let a, b, c;
let a, b = value & 65280;
if (littleEndian) {
c = value >> 16 & 255;
b = value >> 8 & 255;
b |= value >> 16 & 255;
a = value & 255;
} else {
c = value & 255;
b = value >> 8 & 255;
b |= value & 255;
a = value >> 16 & 255;
}
if ((byteOffset |= 0) < 0) {
// Trigger native OOB exception.
dataView.setUint8(byteOffset, a);
}
dataView.setUint16(byteOffset + 1, b << 8 | c);
dataView.setUint16(byteOffset + 1, b);
dataView.setUint8(byteOffset, a);
}

0 comments on commit 7c55baa

Please sign in to comment.