es6.reflect.define-property.js 799 B

123456789101112131415161718192021222324
  1. // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
  2. var dP = require('./_object-dp');
  3. var $export = require('./_export');
  4. var anObject = require('./_an-object');
  5. var toPrimitive = require('./_to-primitive');
  6. // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
  7. $export($export.S + $export.F * require('./_fails')(function () {
  8. // eslint-disable-next-line no-undef
  9. Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });
  10. }), 'Reflect', {
  11. defineProperty: function defineProperty(target, propertyKey, attributes) {
  12. anObject(target);
  13. propertyKey = toPrimitive(propertyKey, true);
  14. anObject(attributes);
  15. try {
  16. dP.f(target, propertyKey, attributes);
  17. return true;
  18. } catch (e) {
  19. return false;
  20. }
  21. }
  22. });