diff options
author | Richard Viney <richard.viney@gmail.com> | 2024-05-19 21:39:43 +1200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-05-20 14:29:40 +0100 |
commit | 9610f1c05270ab88ea9209c16bea5ba1873a9aaa (patch) | |
tree | 92f8867834c8e359c25beb7221434ffb7a4606dc /src | |
parent | 6814f28bc59cc4efe0cf34eefc519209f1d8a9ec (diff) | |
download | gleam_stdlib-9610f1c05270ab88ea9209c16bea5ba1873a9aaa.tar.gz gleam_stdlib-9610f1c05270ab88ea9209c16bea5ba1873a9aaa.zip |
Fix `bit_array` slices of slices on JavaScript
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam_stdlib.mjs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index d921c63..256850a 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -362,7 +362,8 @@ export function bit_array_slice(bits, position, length) { const start = Math.min(position, position + length); const end = Math.max(position, position + length); if (start < 0 || end > bits.length) return new Error(Nil); - const buffer = new Uint8Array(bits.buffer.buffer, start, Math.abs(length)); + const byteOffset = bits.buffer.byteOffset + start; + const buffer = new Uint8Array(bits.buffer.buffer, byteOffset, Math.abs(length)); return new Ok(new BitArray(buffer)); } |