[d565449] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = _set;
|
---|
| 7 | var _superPropBase = require("./superPropBase.js");
|
---|
| 8 | var _defineProperty = require("./defineProperty.js");
|
---|
| 9 | function set(target, property, value, receiver) {
|
---|
| 10 | if (typeof Reflect !== "undefined" && Reflect.set) {
|
---|
| 11 | set = Reflect.set;
|
---|
| 12 | } else {
|
---|
| 13 | set = function set(target, property, value, receiver) {
|
---|
| 14 | var base = (0, _superPropBase.default)(target, property);
|
---|
| 15 | var desc;
|
---|
| 16 | if (base) {
|
---|
| 17 | desc = Object.getOwnPropertyDescriptor(base, property);
|
---|
| 18 | if (desc.set) {
|
---|
| 19 | desc.set.call(receiver, value);
|
---|
| 20 | return true;
|
---|
| 21 | } else if (!desc.writable) {
|
---|
| 22 | return false;
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | desc = Object.getOwnPropertyDescriptor(receiver, property);
|
---|
| 26 | if (desc) {
|
---|
| 27 | if (!desc.writable) {
|
---|
| 28 | return false;
|
---|
| 29 | }
|
---|
| 30 | desc.value = value;
|
---|
| 31 | Object.defineProperty(receiver, property, desc);
|
---|
| 32 | } else {
|
---|
| 33 | (0, _defineProperty.default)(receiver, property, value);
|
---|
| 34 | }
|
---|
| 35 | return true;
|
---|
| 36 | };
|
---|
| 37 | }
|
---|
| 38 | return set(target, property, value, receiver);
|
---|
| 39 | }
|
---|
| 40 | function _set(target, property, value, receiver, isStrict) {
|
---|
| 41 | var s = set(target, property, value, receiver || target);
|
---|
| 42 | if (!s && isStrict) {
|
---|
| 43 | throw new TypeError("failed to set property");
|
---|
| 44 | }
|
---|
| 45 | return value;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | //# sourceMappingURL=set.js.map
|
---|