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.

31 lines
1.2 KiB

4 years ago
  1. 'use strict';
  2. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  3. var clone = require('../helpers/clone');
  4. module.exports = function concat(collectionOrArrayOrObject) {
  5. var list = collectionOrArrayOrObject;
  6. if (collectionOrArrayOrObject instanceof this.constructor) {
  7. list = collectionOrArrayOrObject.all();
  8. } else if ((typeof collectionOrArrayOrObject === 'undefined' ? 'undefined' : _typeof(collectionOrArrayOrObject)) === 'object') {
  9. list = [];
  10. Object.keys(collectionOrArrayOrObject).forEach(function (property) {
  11. list.push(collectionOrArrayOrObject[property]);
  12. });
  13. }
  14. var collection = clone(this.items);
  15. list.forEach(function (item) {
  16. if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object') {
  17. Object.keys(item).forEach(function (key) {
  18. return collection.push(item[key]);
  19. });
  20. } else {
  21. collection.push(item);
  22. }
  23. });
  24. return new this.constructor(collection);
  25. };