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