Skip to content

Commit

Permalink
Fix bytesToNumber() in case of 0/false
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Nov 9, 2023
1 parent f9a4c4c commit 39c0237
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const numberToBytes = (uint32Value: number) => {
};

export const bytesToNumber = function (byteArray: Uint8Array): number {
if (!byteArray || byteArray?.length === 0) {
return 0;
}

const length = byteArray.length;

const buffer = Buffer.from(byteArray);
Expand Down

0 comments on commit 39c0237

Please sign in to comment.