array-buffer-is-detached.js 513 B

1234567891011121314151617
  1. 'use strict';
  2. var globalThis = require('../internals/global-this');
  3. var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-basic-detection');
  4. var arrayBufferByteLength = require('../internals/array-buffer-byte-length');
  5. var DataView = globalThis.DataView;
  6. module.exports = function (O) {
  7. if (!NATIVE_ARRAY_BUFFER || arrayBufferByteLength(O) !== 0) return false;
  8. try {
  9. // eslint-disable-next-line no-new -- thrower
  10. new DataView(O);
  11. return false;
  12. } catch (error) {
  13. return true;
  14. }
  15. };