Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.reflect.define-property.js 1.1KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var DESCRIPTORS = require('../internals/descriptors');
  4. var anObject = require('../internals/an-object');
  5. var toPropertyKey = require('../internals/to-property-key');
  6. var definePropertyModule = require('../internals/object-define-property');
  7. var fails = require('../internals/fails');
  8. // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
  9. var ERROR_INSTEAD_OF_FALSE = fails(function () {
  10. // eslint-disable-next-line es/no-reflect -- required for testing
  11. Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 });
  12. });
  13. // `Reflect.defineProperty` method
  14. // https://tc39.es/ecma262/#sec-reflect.defineproperty
  15. $({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, {
  16. defineProperty: function defineProperty(target, propertyKey, attributes) {
  17. anObject(target);
  18. var key = toPropertyKey(propertyKey);
  19. anObject(attributes);
  20. try {
  21. definePropertyModule.f(target, key, attributes);
  22. return true;
  23. } catch (error) {
  24. return false;
  25. }
  26. }
  27. });