source: trip-planner-front/node_modules/core-js/modules/es.reflect.set.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1var $ = require('../internals/export');
2var anObject = require('../internals/an-object');
3var isObject = require('../internals/is-object');
4var has = require('../internals/has');
5var fails = require('../internals/fails');
6var definePropertyModule = require('../internals/object-define-property');
7var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
8var getPrototypeOf = require('../internals/object-get-prototype-of');
9var createPropertyDescriptor = require('../internals/create-property-descriptor');
10
11// `Reflect.set` method
12// https://tc39.es/ecma262/#sec-reflect.set
13function set(target, propertyKey, V /* , receiver */) {
14 var receiver = arguments.length < 4 ? target : arguments[3];
15 var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);
16 var existingDescriptor, prototype;
17 if (!ownDescriptor) {
18 if (isObject(prototype = getPrototypeOf(target))) {
19 return set(prototype, propertyKey, V, receiver);
20 }
21 ownDescriptor = createPropertyDescriptor(0);
22 }
23 if (has(ownDescriptor, 'value')) {
24 if (ownDescriptor.writable === false || !isObject(receiver)) return false;
25 if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) {
26 if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
27 existingDescriptor.value = V;
28 definePropertyModule.f(receiver, propertyKey, existingDescriptor);
29 } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V));
30 return true;
31 }
32 return ownDescriptor.set === undefined ? false : (ownDescriptor.set.call(receiver, V), true);
33}
34
35// MS Edge 17-18 Reflect.set allows setting the property to object
36// with non-writable property on the prototype
37var MS_EDGE_BUG = fails(function () {
38 var Constructor = function () { /* empty */ };
39 var object = definePropertyModule.f(new Constructor(), 'a', { configurable: true });
40 // eslint-disable-next-line es/no-reflect -- required for testing
41 return Reflect.set(Constructor.prototype, 'a', 1, object) !== false;
42});
43
44$({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, {
45 set: set
46});
Note: See TracBrowser for help on using the repository browser.