object-is-extensible.js 774 B

12345678910111213141516
  1. var fails = require('../internals/fails');
  2. var isObject = require('../internals/is-object');
  3. var classof = require('../internals/classof-raw');
  4. var ARRAY_BUFFER_NON_EXTENSIBLE = require('../internals/array-buffer-non-extensible');
  5. // eslint-disable-next-line es/no-object-isextensible -- safe
  6. var $isExtensible = Object.isExtensible;
  7. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  8. // `Object.isExtensible` method
  9. // https://tc39.es/ecma262/#sec-object.isextensible
  10. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  11. if (!isObject(it)) return false;
  12. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  13. return $isExtensible ? $isExtensible(it) : true;
  14. } : $isExtensible;