Skip to content

Commit

Permalink
Merge pull request #59 from snyamathi/SharedArrayBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop authored May 3, 2021
2 parents 4b1c0c7 + 6a8d35c commit 7d2a968
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions support/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,23 @@ function isDataView(value) {
}
exports.isDataView = isDataView;

// Store a copy of SharedArrayBuffer in case it's deleted elsewhere
var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined;
function isSharedArrayBufferToString(value) {
return ObjectToString(value) === '[object SharedArrayBuffer]';
}
isSharedArrayBufferToString.working = (
typeof SharedArrayBuffer !== 'undefined' &&
isSharedArrayBufferToString(new SharedArrayBuffer())
);
function isSharedArrayBuffer(value) {
if (typeof SharedArrayBuffer === 'undefined') {
if (typeof SharedArrayBufferCopy === 'undefined') {
return false;
}

if (typeof isSharedArrayBufferToString.working === 'undefined') {
isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy());
}

return isSharedArrayBufferToString.working
? isSharedArrayBufferToString(value)
: value instanceof SharedArrayBuffer;
: value instanceof SharedArrayBufferCopy;
}
exports.isSharedArrayBuffer = isSharedArrayBuffer;

Expand Down

0 comments on commit 7d2a968

Please sign in to comment.