Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better TypedArray type checking #153929

Merged
merged 1 commit into from Jul 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/vs/base/common/types.ts
Expand Up @@ -47,18 +47,9 @@ export function isObject(obj: unknown): obj is Object {
* @returns whether the provided parameter is of type `Buffer` or Uint8Array dervived type
*/
export function isTypedArray(obj: unknown): obj is Object {
const TypedArray = Object.getPrototypeOf(Uint8Array);
return typeof obj === 'object'
&& (obj instanceof Uint8Array ||
obj instanceof Uint16Array ||
obj instanceof Uint32Array ||
obj instanceof Float32Array ||
obj instanceof Float64Array ||
obj instanceof Int8Array ||
obj instanceof Int16Array ||
obj instanceof Int32Array ||
obj instanceof BigInt64Array ||
obj instanceof BigUint64Array ||
obj instanceof Uint8ClampedArray);
&& obj instanceof TypedArray;
}

/**
Expand Down