es.object.prevent-extensions.js 771 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-x/no-object-preventextensions -- safe
  7. var $preventExtensions = Object.preventExtensions;
  8. var FAILS_ON_PRIMITIVES = fails(function () { $preventExtensions(1); });
  9. // `Object.preventExtensions` method
  10. // https://tc39.es/ecma262/#sec-object.preventextensions
  11. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  12. preventExtensions: function preventExtensions(it) {
  13. return $preventExtensions && isObject(it) ? $preventExtensions(onFreeze(it)) : it;
  14. }
  15. });