MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromIterator

Function fromIterator

packages/effect/src/Channel.ts:658–667  ·  view source on GitHub ↗
(iterator: LazyArg<Iterator<A, L>>)

Source from the content-addressed store, hash-verified

656 * @since 4.0.0
657 */
658export const fromIterator = <A, L>(iterator: LazyArg<Iterator<A, L>>): Channel<A, never, L> =>
659 fromPull(
660 Effect.sync(() => {
661 const iter = iterator()
662 return Effect.suspend(() => {
663 const state = iter.next()
664 return state.done ? Cause.done(state.value) : Effect.succeed(state.value)
665 })
666 })
667 )
668
669/**
670 * Creates a `Channel` that emits all elements from an array.

Callers 1

fromIterableFunction · 0.85

Calls 5

fromPullFunction · 0.70
nextMethod · 0.65
syncMethod · 0.45
doneMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected