es.object.seal.js 653 B

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