Skip to content

Commit d530159

Browse files
committed
Simplify abytes
1 parent 389662d commit d530159

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ function isBytes(a: unknown): a is Uint8Array {
1414
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
1515
}
1616
/** Asserts something is Uint8Array. */
17-
function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {
17+
function abytes(b: Uint8Array | undefined): void {
1818
if (!isBytes(b)) throw new Error('Uint8Array expected');
19-
if (lengths.length > 0 && !lengths.includes(b.length))
20-
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
2119
}
2220

2321
function isArrayOf(isString: boolean, arr: any[]) {
@@ -30,8 +28,6 @@ function isArrayOf(isString: boolean, arr: any[]) {
3028
}
3129
}
3230

33-
// no abytes: seems to have 10% slowdown. Why?!
34-
3531
function afn(input: Function): input is Function {
3632
if (typeof input !== 'function') throw new Error('function expected');
3733
return true;

0 commit comments

Comments
 (0)