objectSpread2.js 1.1 KB

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