Skip to content

Commit

Permalink
utils: improve isBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Dec 10, 2023
1 parent ada1ea5 commit 30f68c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/abstract/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 30f68c9

Please sign in to comment.