1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-05 13:59:01 -05:00

fix(ext/node): util.types.isSharedArrayBuffer (#17836)

This commit is contained in:
Yoshiya Hinosawa 2023-02-26 11:23:53 +09:00
parent a07adc1a88
commit e5ff08d85c
2 changed files with 7 additions and 11 deletions

View file

@ -746,7 +746,7 @@
"test-util-isDeepStrictEqual.js",
"test-util-promisify.js",
"test-util-types-exists.js",
"TODO:test-util-types.js",
"test-util-types.js",
"test-util.js",
"test-vm-static-this.js",
"test-webcrypto-sign-verify.js",

View file

@ -57,12 +57,7 @@ const _getArrayBufferByteLength = Object.getOwnPropertyDescriptor(
)!.get!;
// https://tc39.es/ecma262/#sec-get-sharedarraybuffer.prototype.bytelength
const _getSharedArrayBufferByteLength = globalThis.SharedArrayBuffer
? Object.getOwnPropertyDescriptor(
SharedArrayBuffer.prototype,
"byteLength",
)!.get!
: undefined;
let _getSharedArrayBufferByteLength;
// https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
const _getTypedArrayToStringTag = Object.getOwnPropertyDescriptor(
@ -285,10 +280,11 @@ export function isSetIterator(
export function isSharedArrayBuffer(
value: unknown,
): value is SharedArrayBuffer {
// SharedArrayBuffer is not available on this runtime
if (_getSharedArrayBufferByteLength === undefined) {
return false;
}
// TODO(kt3k): add SharedArrayBuffer to primordials
_getSharedArrayBufferByteLength ??= Object.getOwnPropertyDescriptor(
SharedArrayBuffer.prototype,
"byteLength",
)!.get!;
try {
_getSharedArrayBufferByteLength.call(value);