From e0ad0530f64d7cc01514b65d819b7f76db5f0da4 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 10 Nov 2024 21:42:10 +0000 Subject: [PATCH] Speed-up byte array checks --- src/abstract/utils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/abstract/utils.ts b/src/abstract/utils.ts index 26a223b..81c4001 100644 --- a/src/abstract/utils.ts +++ b/src/abstract/utils.ts @@ -17,10 +17,7 @@ export type CHash = { export type FHash = (message: Uint8Array | string) => Uint8Array; export function isBytes(a: unknown): a is Uint8Array { - return ( - a instanceof Uint8Array || - (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array') - ); + return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'); } export function abytes(item: unknown): void {