Skip to content

Commit

Permalink
_assert: small edits
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Dec 10, 2023
1 parent d19031b commit 151016c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/_assert.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function number(n: number) {
if (!Number.isSafeInteger(n) || n < 0) throw new Error(`Wrong positive integer: ${n}`);
if (!Number.isSafeInteger(n) || n < 0) throw new Error(`wrong positive integer: ${n}`);
}

function bool(b: boolean) {
if (typeof b !== 'boolean') throw new Error(`Expected boolean, not ${b}`);
if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`);
}

function isBytes(a: unknown): a is Uint8Array {
Expand All @@ -15,9 +15,9 @@ function isBytes(a: unknown): a is Uint8Array {
}

function bytes(b: Uint8Array | undefined, ...lengths: number[]) {
if (!isBytes(b)) throw new Error('Expected Uint8Array');
if (!isBytes(b)) throw new Error('Uint8Array expected');
if (lengths.length > 0 && !lengths.includes(b.length))
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
}

export type Hash = {
Expand Down

0 comments on commit 151016c

Please sign in to comment.