CreateNonEnumerableDataPropertyOrThrow.js 737 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
  4. var IsPropertyKey = require('./IsPropertyKey');
  5. var Type = require('./Type');
  6. // https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow
  7. module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) {
  8. if (Type(O) !== 'Object') {
  9. throw new $TypeError('Assertion failed: Type(O) is not Object');
  10. }
  11. if (!IsPropertyKey(P)) {
  12. throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
  13. }
  14. var newDesc = {
  15. '[[Configurable]]': true,
  16. '[[Enumerable]]': false,
  17. '[[Value]]': V,
  18. '[[Writable]]': true
  19. };
  20. return DefinePropertyOrThrow(O, P, newDesc);
  21. };