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.

148 lines
7.7 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. function Collection(collection) {
  4. if (collection !== undefined && !Array.isArray(collection) && (typeof collection === 'undefined' ? 'undefined' : _typeof(collection)) !== 'object') {
  5. this.items = [collection];
  6. } else if (collection instanceof this.constructor) {
  7. this.items = collection.all();
  8. } else {
  9. this.items = collection || [];
  10. }
  11. }
  12. /**
  13. * Symbol.iterator
  14. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator
  15. */
  16. var SymbolIterator = require('./methods/symbol.iterator');
  17. if (typeof Symbol !== 'undefined') {
  18. Collection.prototype[Symbol.iterator] = SymbolIterator;
  19. }
  20. /**
  21. * Support JSON.stringify
  22. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
  23. */
  24. Collection.prototype.toJSON = function toJSON() {
  25. return this.items;
  26. };
  27. Collection.prototype.all = require('./methods/all');
  28. Collection.prototype.average = require('./methods/average');
  29. Collection.prototype.avg = require('./methods/average');
  30. Collection.prototype.chunk = require('./methods/chunk');
  31. Collection.prototype.collapse = require('./methods/collapse');
  32. Collection.prototype.combine = require('./methods/combine');
  33. Collection.prototype.concat = require('./methods/concat');
  34. Collection.prototype.contains = require('./methods/contains');
  35. Collection.prototype.count = require('./methods/count');
  36. Collection.prototype.countBy = require('./methods/countBy');
  37. Collection.prototype.crossJoin = require('./methods/crossJoin');
  38. Collection.prototype.dd = require('./methods/dd');
  39. Collection.prototype.diff = require('./methods/diff');
  40. Collection.prototype.diffAssoc = require('./methods/diffAssoc');
  41. Collection.prototype.diffKeys = require('./methods/diffKeys');
  42. Collection.prototype.dump = require('./methods/dump');
  43. Collection.prototype.duplicates = require('./methods/duplicates');
  44. Collection.prototype.each = require('./methods/each');
  45. Collection.prototype.eachSpread = require('./methods/eachSpread');
  46. Collection.prototype.every = require('./methods/every');
  47. Collection.prototype.except = require('./methods/except');
  48. Collection.prototype.filter = require('./methods/filter');
  49. Collection.prototype.first = require('./methods/first');
  50. Collection.prototype.firstWhere = require('./methods/firstWhere');
  51. Collection.prototype.flatMap = require('./methods/flatMap');
  52. Collection.prototype.flatten = require('./methods/flatten');
  53. Collection.prototype.flip = require('./methods/flip');
  54. Collection.prototype.forPage = require('./methods/forPage');
  55. Collection.prototype.forget = require('./methods/forget');
  56. Collection.prototype.get = require('./methods/get');
  57. Collection.prototype.groupBy = require('./methods/groupBy');
  58. Collection.prototype.has = require('./methods/has');
  59. Collection.prototype.implode = require('./methods/implode');
  60. Collection.prototype.intersect = require('./methods/intersect');
  61. Collection.prototype.intersectByKeys = require('./methods/intersectByKeys');
  62. Collection.prototype.isEmpty = require('./methods/isEmpty');
  63. Collection.prototype.isNotEmpty = require('./methods/isNotEmpty');
  64. Collection.prototype.join = require('./methods/join');
  65. Collection.prototype.keyBy = require('./methods/keyBy');
  66. Collection.prototype.keys = require('./methods/keys');
  67. Collection.prototype.last = require('./methods/last');
  68. Collection.prototype.macro = require('./methods/macro');
  69. Collection.prototype.make = require('./methods/make');
  70. Collection.prototype.map = require('./methods/map');
  71. Collection.prototype.mapSpread = require('./methods/mapSpread');
  72. Collection.prototype.mapToDictionary = require('./methods/mapToDictionary');
  73. Collection.prototype.mapInto = require('./methods/mapInto');
  74. Collection.prototype.mapToGroups = require('./methods/mapToGroups');
  75. Collection.prototype.mapWithKeys = require('./methods/mapWithKeys');
  76. Collection.prototype.max = require('./methods/max');
  77. Collection.prototype.median = require('./methods/median');
  78. Collection.prototype.merge = require('./methods/merge');
  79. Collection.prototype.mergeRecursive = require('./methods/mergeRecursive');
  80. Collection.prototype.min = require('./methods/min');
  81. Collection.prototype.mode = require('./methods/mode');
  82. Collection.prototype.nth = require('./methods/nth');
  83. Collection.prototype.only = require('./methods/only');
  84. Collection.prototype.pad = require('./methods/pad');
  85. Collection.prototype.partition = require('./methods/partition');
  86. Collection.prototype.pipe = require('./methods/pipe');
  87. Collection.prototype.pluck = require('./methods/pluck');
  88. Collection.prototype.pop = require('./methods/pop');
  89. Collection.prototype.prepend = require('./methods/prepend');
  90. Collection.prototype.pull = require('./methods/pull');
  91. Collection.prototype.push = require('./methods/push');
  92. Collection.prototype.put = require('./methods/put');
  93. Collection.prototype.random = require('./methods/random');
  94. Collection.prototype.reduce = require('./methods/reduce');
  95. Collection.prototype.reject = require('./methods/reject');
  96. Collection.prototype.replace = require('./methods/replace');
  97. Collection.prototype.replaceRecursive = require('./methods/replaceRecursive');
  98. Collection.prototype.reverse = require('./methods/reverse');
  99. Collection.prototype.search = require('./methods/search');
  100. Collection.prototype.shift = require('./methods/shift');
  101. Collection.prototype.shuffle = require('./methods/shuffle');
  102. Collection.prototype.slice = require('./methods/slice');
  103. Collection.prototype.some = require('./methods/contains');
  104. Collection.prototype.sort = require('./methods/sort');
  105. Collection.prototype.sortBy = require('./methods/sortBy');
  106. Collection.prototype.sortByDesc = require('./methods/sortByDesc');
  107. Collection.prototype.sortKeys = require('./methods/sortKeys');
  108. Collection.prototype.sortKeysDesc = require('./methods/sortKeysDesc');
  109. Collection.prototype.splice = require('./methods/splice');
  110. Collection.prototype.split = require('./methods/split');
  111. Collection.prototype.sum = require('./methods/sum');
  112. Collection.prototype.take = require('./methods/take');
  113. Collection.prototype.tap = require('./methods/tap');
  114. Collection.prototype.times = require('./methods/times');
  115. Collection.prototype.toArray = require('./methods/toArray');
  116. Collection.prototype.toJson = require('./methods/toJson');
  117. Collection.prototype.transform = require('./methods/transform');
  118. Collection.prototype.unless = require('./methods/unless');
  119. Collection.prototype.unlessEmpty = require('./methods/whenNotEmpty');
  120. Collection.prototype.unlessNotEmpty = require('./methods/whenEmpty');
  121. Collection.prototype.union = require('./methods/union');
  122. Collection.prototype.unique = require('./methods/unique');
  123. Collection.prototype.unwrap = require('./methods/unwrap');
  124. Collection.prototype.values = require('./methods/values');
  125. Collection.prototype.when = require('./methods/when');
  126. Collection.prototype.whenEmpty = require('./methods/whenEmpty');
  127. Collection.prototype.whenNotEmpty = require('./methods/whenNotEmpty');
  128. Collection.prototype.where = require('./methods/where');
  129. Collection.prototype.whereBetween = require('./methods/whereBetween');
  130. Collection.prototype.whereIn = require('./methods/whereIn');
  131. Collection.prototype.whereInstanceOf = require('./methods/whereInstanceOf');
  132. Collection.prototype.whereNotBetween = require('./methods/whereNotBetween');
  133. Collection.prototype.whereNotIn = require('./methods/whereNotIn');
  134. Collection.prototype.wrap = require('./methods/wrap');
  135. Collection.prototype.zip = require('./methods/zip');
  136. var collect = function collect(collection) {
  137. return new Collection(collection);
  138. };
  139. module.exports = collect;
  140. module.exports.collect = collect;
  141. module.exports.default = collect;