You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB

4 years ago
  1. import defineProperty from "./defineProperty";
  2. function ownKeys(object, enumerableOnly) {
  3. var keys = Object.keys(object);
  4. if (Object.getOwnPropertySymbols) {
  5. var symbols = Object.getOwnPropertySymbols(object);
  6. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  7. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  8. });
  9. keys.push.apply(keys, symbols);
  10. }
  11. return keys;
  12. }
  13. export default function _objectSpread2(target) {
  14. for (var i = 1; i < arguments.length; i++) {
  15. var source = arguments[i] != null ? arguments[i] : {};
  16. if (i % 2) {
  17. ownKeys(Object(source), true).forEach(function (key) {
  18. defineProperty(target, key, source[key]);
  19. });
  20. } else if (Object.getOwnPropertyDescriptors) {
  21. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  22. } else {
  23. ownKeys(Object(source)).forEach(function (key) {
  24. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  25. });
  26. }
  27. }
  28. return target;
  29. }