es.object.is-sealed.js 812 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-x/no-object-issealed -- safe
  7. var $isSealed = Object.isSealed;
  8. var FAILS_ON_PRIMITIVES = fails(function () { $isSealed(1); });
  9. // `Object.isSealed` method
  10. // https://tc39.es/ecma262/#sec-object.issealed
  11. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE }, {
  12. isSealed: function isSealed(it) {
  13. if (!isObject(it)) return true;
  14. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return true;
  15. return $isSealed ? $isSealed(it) : false;
  16. }
  17. });