Skip to content

Commit

Permalink
Fix deserialization of sliced bit arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-viney committed Jun 19, 2024
1 parent a4ee080 commit d2369a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ieee_float_js.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ function to_bytes_32(f, littleEndian) {
return new BitArray(u8Array);
}

function from_bytes_32(f, littleEndian) {
if (f.length !== 4) {
function from_bytes_32(bitArray, littleEndian) {
if (bitArray.length !== 4) {
return new Error(Nil);
}

const view = new DataView(f.buffer.buffer);
const view = new DataView(bitArray.buffer.buffer, bitArray.buffer.byteOffset);

return view.getFloat32(0, littleEndian);
}
Expand All @@ -90,12 +90,12 @@ function to_bytes_64(f, littleEndian) {
return new BitArray(u8Array);
}

function from_bytes_64(f, littleEndian) {
if (f.length !== 8) {
function from_bytes_64(bitArray, littleEndian) {
if (bitArray.length !== 8) {
return new Error(Nil);
}

const view = new DataView(f.buffer.buffer);
const view = new DataView(bitArray.buffer.buffer, bitArray.buffer.byteOffset);

return view.getFloat64(0, littleEndian);
}
Expand Down

0 comments on commit d2369a0

Please sign in to comment.