Skip to main content

Function: each()

Returns an iterable equivalent to iterable that applies fn to each value of iterable as it is iterated.

Example

import { each, pipe, reduce, toArray } from 'lfi'

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

Since

v0.0.1

Call Signature

each<From, To>(fn): (iterable) => Iterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => asserts value is To

Returns

Function

Parameters

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

side-effects.d.ts:29

Call Signature

each<From, To>(fn, iterable): Iterable<To, any, any>

Type Parameters

From

To

Parameters

fn

(value) => asserts value is To

iterable

Iterable<From, any, any>

Returns

Iterable<To, any, any>

Defined in

side-effects.d.ts:32

Call Signature

each<Value>(fn): (iterable) => Iterable<Value, any, any>

Type Parameters

Value

Parameters

fn

(value) => unknown

Returns

Function

Parameters

iterable

Iterable<Value, any, any>

Returns

Iterable<Value, any, any>

Defined in

side-effects.d.ts:37

Call Signature

each<Value>(fn, iterable): Iterable<Value, any, any>

Type Parameters

Value

Parameters

fn

(value) => unknown

iterable

Iterable<Value, any, any>

Returns

Iterable<Value, any, any>

Defined in

side-effects.d.ts:40