objectSpread2.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import _Object$keys from "@babel/runtime-corejs3/core-js/object/keys";
  2. import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js/object/get-own-property-symbols";
  3. import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
  4. import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
  5. import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
  6. import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptors";
  7. import _Object$defineProperties from "@babel/runtime-corejs3/core-js/object/define-properties";
  8. import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
  9. import defineProperty from "./defineProperty.js";
  10. function ownKeys(object, enumerableOnly) {
  11. var keys = _Object$keys(object);
  12. if (_Object$getOwnPropertySymbols) {
  13. var symbols = _Object$getOwnPropertySymbols(object);
  14. if (enumerableOnly) {
  15. symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  16. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  17. });
  18. }
  19. keys.push.apply(keys, symbols);
  20. }
  21. return keys;
  22. }
  23. export default function _objectSpread2(target) {
  24. for (var i = 1; i < arguments.length; i++) {
  25. var source = arguments[i] != null ? arguments[i] : {};
  26. if (i % 2) {
  27. var _context;
  28. _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) {
  29. defineProperty(target, key, source[key]);
  30. });
  31. } else if (_Object$getOwnPropertyDescriptors) {
  32. _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source));
  33. } else {
  34. var _context2;
  35. _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
  36. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  37. });
  38. }
  39. }
  40. return target;
  41. }