node_modules/es-abstract/2017/IsDetachedBuffer.js in immosquare-cleaner-0.1.32 vs node_modules/es-abstract/2017/IsDetachedBuffer.js in immosquare-cleaner-0.1.38

- old
+ new

@@ -1,23 +1,24 @@ 'use strict'; -var GetIntrinsic = require('get-intrinsic'); +var $TypeError = require('es-errors/type'); -var $TypeError = GetIntrinsic('%TypeError%'); - var $byteLength = require('array-buffer-byte-length'); - +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bind/callBound'); var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); -var availableTypedArrays = require('available-typed-arrays')(); +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); -// https://262.ecma-international.org/6.0/#sec-isdetachedbuffer +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer module.exports = function IsDetachedBuffer(arrayBuffer) { - if (!isArrayBuffer(arrayBuffer)) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); } - if ($byteLength(arrayBuffer) === 0) { + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { try { new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new } catch (error) { return !!error && error.name === 'TypeError'; }