From 39c023776dc140864b19fa73f00e905b4b4c63e5 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 9 Nov 2023 14:34:50 +0200 Subject: [PATCH] Fix `bytesToNumber()` in case of 0/false --- src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 37de02f..ce6de12 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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);