UNPKG

1.49 kBJavaScriptView Raw
1import _Reflect$set from "core-js/library/fn/reflect/set.js";
2import _Object$getOwnPropertyDescriptor from "core-js/library/fn/object/get-own-property-descriptor.js";
3import _Object$defineProperty from "core-js/library/fn/object/define-property.js";
4import superPropBase from "./superPropBase.js";
5import defineProperty from "./defineProperty.js";
6function set(target, property, value, receiver) {
7 if (typeof Reflect !== "undefined" && _Reflect$set) {
8 set = _Reflect$set;
9 } else {
10 set = function set(target, property, value, receiver) {
11 var base = superPropBase(target, property);
12 var desc;
13 if (base) {
14 desc = _Object$getOwnPropertyDescriptor(base, property);
15 if (desc.set) {
16 desc.set.call(receiver, value);
17 return true;
18 } else if (!desc.writable) {
19 return false;
20 }
21 }
22 desc = _Object$getOwnPropertyDescriptor(receiver, property);
23 if (desc) {
24 if (!desc.writable) {
25 return false;
26 }
27 desc.value = value;
28 _Object$defineProperty(receiver, property, desc);
29 } else {
30 defineProperty(receiver, property, value);
31 }
32 return true;
33 };
34 }
35 return set(target, property, value, receiver);
36}
37export default function _set(target, property, value, receiver, isStrict) {
38 var s = set(target, property, value, receiver || target);
39 if (!s && isStrict) {
40 throw new TypeError('failed to set property');
41 }
42 return value;
43}
\No newline at end of file