es.object.is-frozen.js 810 B

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