fx-flow v0.7.0 / pipe/lazy / peek
Function: peek()
peek(fn, iterable)
peek<
A
>(fn
,iterable
):IterableIterator
<A
>
Call fn
for each item in the iterable/asyncIterable and return the original iterable/asyncIterable.
Type parameters
• A
Parameters
• fn
• iterable: Iterable
<A
>
Returns
Example
typescript
const iterator = peek(console.log, [1, 2, 3])
for (const v of iterator) {
// log 1, 2, 3
// v = 1, 2, 3
}
const iterator2 = peek(
(v) => {
v.a = 'b'
},
[{ a: 'a' }]
)
for (const v of iterator) {
console.log(v) // log {a: 'b'}
}
Source
packages/core/src/pipe/lazy/peek.ts:32
peek(fn, iterable)
peek<
A
>(fn
,iterable
):AsyncIterableIterator
<A
>
Type parameters
• A
Parameters
• fn
• iterable: AsyncIterable
<A
>
Returns
Source
packages/core/src/pipe/lazy/peek.ts:33
peek(fn)
peek<
A
>(fn
): (iterable
) =>IteratorReturnValue
<UniversalIterable
<A
>>
Type parameters
• A
Parameters
• fn
Returns
Function
Parameters
• iterable: UniversalIterable
<A
>
Returns
IteratorReturnValue
<UniversalIterable
<A
>>