| 1558 | * Accumulates incoming elements into an array. |
| 1559 | * |
| 1560 | * **When to use** |
| 1561 | * |
| 1562 | * Use when you need a sink result containing all upstream input elements. |
| 1563 | * |
| 1564 | * @see {@link take} for collecting only a fixed number of input elements |
| 1565 | * |
| 1566 | * @category constructors |
| 1567 | * @since 4.0.0 |
| 1568 | */ |
| 1569 | export const collect = <In>(): Sink<Array<In>, In> => |
| 1570 | reduceArray(Arr.empty<In>, (s, arr) => { |
| 1571 | s.push(...arr) |
| 1572 | return s |
| 1573 | }) |
| 1574 | |
| 1575 | /** |
| 1576 | * Collects the longest input prefix whose elements satisfy the predicate or |
| 1577 | * refinement. |
| 1578 | * |
| 1579 | * **Details** |
| 1580 | * |
| 1581 | * The first failing input is consumed and excluded from the result. Any later |
| 1582 | * elements from the same pulled array are returned as leftovers. |