From e67c46e60b3d1591de43a2971c10276a4a2c0450 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 20 Jul 2025 03:43:03 -0700 Subject: [PATCH] Fix worker response format. Add cause information to hex convert function. --- src/lib/convert.ts | 6 +++--- src/lib/workers/worker-interface.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/convert.ts b/src/lib/convert.ts index 091d6ac..53908f0 100644 --- a/src/lib/convert.ts +++ b/src/lib/convert.ts @@ -279,15 +279,15 @@ export class hex { */ static toArray (hex: string, padding: number = 0): number[] { if (typeof hex !== 'string' || !/^[A-Fa-f0-9]+$/i.test(hex)) { - throw new TypeError('Invalid string when converting hex to array') + throw new TypeError('Invalid string when converting hex to array', { cause: hex }) } if (typeof padding !== 'number') { - throw new TypeError('Invalid padding when converting hex to array') + throw new TypeError('Invalid padding when converting hex to array', { cause: padding }) } if (hex.length % 2 === 1) hex = `0${hex}` const hexArray = hex.match(/.{2}/g) if (hexArray == null) { - throw new RangeError('Invalid hex string when converting to array') + throw new RangeError('Invalid hex string when converting to array', { cause: hexArray }) } for (let i = hexArray.length; i < padding; i++) { hexArray.unshift('0') diff --git a/src/lib/workers/worker-interface.ts b/src/lib/workers/worker-interface.ts index 76b03d7..d11da4e 100644 --- a/src/lib/workers/worker-interface.ts +++ b/src/lib/workers/worker-interface.ts @@ -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) } /** -- 2.47.3