es.object.seal.js 612 B

12345678910111213141516
  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. var nativeSeal = Object.seal;
  7. var FAILS_ON_PRIMITIVES = fails(function () { nativeSeal(1); });
  8. // `Object.seal` method
  9. // https://tc39.github.io/ecma262/#sec-object.seal
  10. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  11. seal: function seal(it) {
  12. return nativeSeal && isObject(it) ? nativeSeal(onFreeze(it)) : it;
  13. }
  14. });