es.object.is-frozen.js 800 B

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