es.object.seal.js 639 B

1234567891011121314151617
  1. var $ = require('../internals/export');
  2. var isObject = require('../internals/is-object');
  3. var onFreeze = require('../internals/internal-metadata').onFreeze;
  4. var FREEZING = require('../internals/freezing');
  5. var fails = require('../internals/fails');
  6. // eslint-disable-next-line es/no-object-seal -- safe
  7. var $seal = Object.seal;
  8. var FAILS_ON_PRIMITIVES = fails(function () { $seal(1); });
  9. // `Object.seal` method
  10. // https://tc39.es/ecma262/#sec-object.seal
  11. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  12. seal: function seal(it) {
  13. return $seal && isObject(it) ? $seal(onFreeze(it)) : it;
  14. }
  15. });