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.

24 lines
521 B

4 years ago
  1. # `collapse()`
  2. The collapse method collapses a collection of arrays into a single, flat collection:
  3. ```js
  4. const collection = collect([[1], [{}, 5, {}], ['xoxo']]);
  5. const collapsed = collection.collapse();
  6. collapsed.all();
  7. // [1, {}, 5, {}, 'xoxo']
  8. ```
  9. ```js
  10. const collection = collect([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
  11. const collapsed = collection.collapse();
  12. collapsed.all();
  13. // [1, 2, 3, 4, 5, 6, 7, 8, 9]
  14. ```
  15. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/collapse.js)