Variable: cache()
constcache: <Value>(iterable) =>Iterable<Value>
Defined in: side-effects.d.ts:384
Returns an iterable equivalent to iterable that iterates over iterable at
most once by lazily caching the values from the first iteration.
Type Parameters
Value
Value
Parameters
iterable
Iterable<Value>
Returns
Iterable<Value>
Example
import { each, cache, pipe } from 'lfi'
const iterable = pipe(
[`sloth`, `lazy`, `sleep`],
each(console.log),
cache,
)
// No output
console.log([...iterable])
//=> sloth
//=> lazy
//=> sleep
//=> [ 'sloth', 'lazy', 'sleep' ]
console.log([...iterable])
//=> [ 'sloth', 'lazy', 'sleep' ]
Since
v2.0.0