From 30f68c9e54a57d729896050d6a661bccb0f1fb94 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 10 Dec 2023 23:04:11 +0000 Subject: [PATCH] utils: improve isBytes --- src/abstract/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/abstract/utils.ts b/src/abstract/utils.ts index 7aec03a..0389c3e 100644 --- a/src/abstract/utils.ts +++ b/src/abstract/utils.ts @@ -16,8 +16,11 @@ export type CHash = { }; export type FHash = (message: Uint8Array | string) => Uint8Array; -export function isBytes(a: any): a is Uint8Array { - return a instanceof Uint8Array || a.constructor.name === 'Uint8Array'; +export function isBytes(a: unknown): a is Uint8Array { + return ( + a instanceof Uint8Array || + (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array') + ); } // Array where index 0xf0 (240) is mapped to string 'f0'