Skip to content

Commit a4f0c3b

Browse files
authored
fix: Fix binary util discarding bits when compiling to Wasm (#1589)
1 parent c54dd64 commit a4f0c3b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/util/binary.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function writeI8(value: i32, buffer: Uint8Array, offset: i32): void {
1515

1616
/** Reads a 16-bit integer from the specified buffer. */
1717
export function readI16(buffer: Uint8Array, offset: i32): i32 {
18-
return buffer[offset ]
19-
| buffer[offset + 1] << 8;
18+
return i32(buffer[offset ])
19+
| i32(buffer[offset + 1]) << 8;
2020
}
2121

2222
/** Writes a 16-bit integer to the specified buffer. */
@@ -27,10 +27,10 @@ export function writeI16(value: i32, buffer: Uint8Array, offset: i32): void {
2727

2828
/** Reads a 32-bit integer from the specified buffer. */
2929
export function readI32(buffer: Uint8Array, offset: i32): i32 {
30-
return buffer[offset ]
31-
| buffer[offset + 1] << 8
32-
| buffer[offset + 2] << 16
33-
| buffer[offset + 3] << 24;
30+
return i32(buffer[offset ])
31+
| i32(buffer[offset + 1]) << 8
32+
| i32(buffer[offset + 2]) << 16
33+
| i32(buffer[offset + 3]) << 24;
3434
}
3535

3636
/** Writes a 32-bit integer to the specified buffer. */

0 commit comments

Comments
 (0)