CreateNonEnumerableDataPropertyOrThrow.js 785 B

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