objectSpread2.js 978 B

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