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