Skip to content

Commit 543e776

Browse files
committed
Update isTypedArray to use ArrayBuffer.isView
1 parent 2d9d8f1 commit 543e776

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/typed-arrays.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ export class TypedArrayViewGenerator {
4848
}
4949
}
5050

51-
5251
export function subarray<T extends TypedArray>(arr: TypedArray, offset: number, length: number): T {
5352
return arr.subarray(offset, offset + length) as T;
5453
}
5554

56-
// TODO: fix better?
57-
export const isTypedArray = (arr: any) =>
58-
arr && typeof arr.length === 'number' && arr.buffer instanceof ArrayBuffer && typeof arr.byteLength === 'number';
55+
export const isTypedArray = (arr: any) => ArrayBuffer.isView(arr) && !(arr instanceof DataView);

0 commit comments

Comments
 (0)