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

Function fromIterator

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

Source from the content-addressed store, hash-verified

721 * @since 4.0.0
722 */
723export const fromIterator = <A, L>(iterator: LazyArg<Iterator<A, L>>): Channel<A, never, L> =>
724 fromPull(
725 Effect.sync(() => {
726 const iter = iterator()
727 return Effect.suspend(() => {
728 const state = iter.next()
729 return state.done ? Cause.done(state.value) : Effect.succeed(state.value)
730 })
731 })
732 )
733
734/**
735 * 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