]> git.codecow.com Git - libnemo.git/commitdiff
Fix worker response format. Add cause information to hex convert function.
authorChris Duncan <chris@zoso.dev>
Sun, 20 Jul 2025 10:43:03 +0000 (03:43 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 20 Jul 2025 10:43:03 +0000 (03:43 -0700)
src/lib/convert.ts
src/lib/workers/worker-interface.ts

index 091d6ac6ac79500bf91ac2edabb289baeb1aff7a..53908f0666bdff4d09fd1580495fb62ff405a339 100644 (file)
@@ -279,15 +279,15 @@ export class hex {
        */\r
        static toArray (hex: string, padding: number = 0): number[] {\r
                if (typeof hex !== 'string' || !/^[A-Fa-f0-9]+$/i.test(hex)) {\r
-                       throw new TypeError('Invalid string when converting hex to array')\r
+                       throw new TypeError('Invalid string when converting hex to array', { cause: hex })\r
                }\r
                if (typeof padding !== 'number') {\r
-                       throw new TypeError('Invalid padding when converting hex to array')\r
+                       throw new TypeError('Invalid padding when converting hex to array', { cause: padding })\r
                }\r
                if (hex.length % 2 === 1) hex = `0${hex}`\r
                const hexArray = hex.match(/.{2}/g)\r
                if (hexArray == null) {\r
-                       throw new RangeError('Invalid hex string when converting to array')\r
+                       throw new RangeError('Invalid hex string when converting to array', { cause: hexArray })\r
                }\r
                for (let i = hexArray.length; i < padding; i++) {\r
                        hexArray.unshift('0')\r
index 76b03d7f6667ec4f3310a16fc2d7292bf3921603..d11da4e2de6ca501ffc6e11e0f76518bfa14d9c1 100644 (file)
@@ -70,7 +70,7 @@ export abstract class WorkerInterface {
                }
                //@ts-expect-error
                BROWSER: postMessage(data, buffers)
-               NODE: parentPort?.postMessage({ data }, buffers)
+               NODE: parentPort?.postMessage(data, buffers)
        }
 
        /**