Skip to content

Commit

Permalink
convert remaining writeUInt32LE functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wikiwong committed Jul 26, 2023
1 parent 3bcaee2 commit cb9a554
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/leb128/src/leb.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ function decodeIntBuffer(encodedBuffer, index) {
}

function encodeInt32(num) {
const buf = bufs.alloc(4);
const buf = new Uint8Array(4);

buf.writeInt32LE(num, 0);
buf[0] = num & 0xff;
buf[1] = (num >> 8) & 0xff;
buf[2] = (num >> 16) & 0xff;
buf[3] = (num >> 24) & 0xff;

const result = encodeIntBuffer(buf);

bufs.free(buf);
return result;
}

Expand Down Expand Up @@ -265,13 +267,15 @@ function decodeUIntBuffer(encodedBuffer, index) {
}

function encodeUInt32(num) {
const buf = bufs.alloc(4);
const buf = new Uint8Array(4);

buf.writeUInt32LE(num, 0);
buf[0] = num & 0xff;
buf[1] = (num >> 8) & 0xff;
buf[2] = (num >> 16) & 0xff;
buf[3] = (num >> 24) & 0xff;

const result = encodeUIntBuffer(buf);

bufs.free(buf);
return result;
}

Expand Down

0 comments on commit cb9a554

Please sign in to comment.