objectSpread2.js 1.0 KB

1234567891011121314151617181920212223
  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. 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. 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. }
  23. module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;