set.js 965 B

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. exports.__esModule = true;
  3. var _getPrototypeOf = require("../core-js/object/get-prototype-of");
  4. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  5. var _getOwnPropertyDescriptor = require("../core-js/object/get-own-property-descriptor");
  6. var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. exports.default = function set(object, property, value, receiver) {
  9. var desc = (0, _getOwnPropertyDescriptor2.default)(object, property);
  10. if (desc === undefined) {
  11. var parent = (0, _getPrototypeOf2.default)(object);
  12. if (parent !== null) {
  13. set(parent, property, value, receiver);
  14. }
  15. } else if ("value" in desc && desc.writable) {
  16. desc.value = value;
  17. } else {
  18. var setter = desc.set;
  19. if (setter !== undefined) {
  20. setter.call(receiver, value);
  21. }
  22. }
  23. return value;
  24. };