Skip to main content

Function: toArray()

toArray<Value>(): Reducer<Value, Value[]>

Returns a Reducer that collects values to an Array.

Type Parameters

Value

Returns

Reducer<Value, Value[]>

Example

import { cycle, pipe, reduce, take, toArray } from 'lfi'

console.log(
pipe(
cycle([`sloth`, `lazy`, `sleep`]),
take(4),
reduce(toArray()),
),
)
//=> [ 'sloth', 'lazy', 'sleep', 'sloth' ]
Playground

Since

v0.0.1

Defined in

collections.d.ts:33