Skip to content

Commit

Permalink
Speed-up byte array checks
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Nov 10, 2024
1 parent 264388c commit e0ad053
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/abstract/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e0ad053

Please sign in to comment.