summaryrefslogtreecommitdiff
path: root/cli/js/web/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/web/util.ts')
-rw-r--r--cli/js/web/util.ts25
1 files changed, 22 insertions, 3 deletions
diff --git a/cli/js/web/util.ts b/cli/js/web/util.ts
index 19a30a675..2d63b4d60 100644
--- a/cli/js/web/util.ts
+++ b/cli/js/web/util.ts
@@ -1,9 +1,28 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-export type TypedArray = Uint8Array | Float32Array | Int32Array;
-const TypedArrayConstructor = Object.getPrototypeOf(Uint8Array);
+export type TypedArray =
+ | Int8Array
+ | Uint8Array
+ | Uint8ClampedArray
+ | Int16Array
+ | Uint16Array
+ | Int32Array
+ | Uint32Array
+ | Float32Array
+ | Float64Array;
+
export function isTypedArray(x: unknown): x is TypedArray {
- return x instanceof TypedArrayConstructor;
+ return (
+ x instanceof Int8Array ||
+ x instanceof Uint8Array ||
+ x instanceof Uint8ClampedArray ||
+ x instanceof Int16Array ||
+ x instanceof Uint16Array ||
+ x instanceof Int32Array ||
+ x instanceof Uint32Array ||
+ x instanceof Float32Array ||
+ x instanceof Float64Array
+ );
}
// @internal