1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 16:13:18 +00:00
musix-oss/node_modules/core-js/modules/es.reflect.define-property.js
2020-03-03 22:30:50 +02:00

29 lines
1.1 KiB
JavaScript

var $ = require('../internals/export');
var DESCRIPTORS = require('../internals/descriptors');
var anObject = require('../internals/an-object');
var toPrimitive = require('../internals/to-primitive');
var definePropertyModule = require('../internals/object-define-property');
var fails = require('../internals/fails');
// MS Edge has broken Reflect.defineProperty - throwing instead of returning false
var ERROR_INSTEAD_OF_FALSE = fails(function () {
// eslint-disable-next-line no-undef
Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 });
});
// `Reflect.defineProperty` method
// https://tc39.github.io/ecma262/#sec-reflect.defineproperty
$({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, {
defineProperty: function defineProperty(target, propertyKey, attributes) {
anObject(target);
var key = toPrimitive(propertyKey, true);
anObject(attributes);
try {
definePropertyModule.f(target, key, attributes);
return true;
} catch (error) {
return false;
}
}
});