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

Function fromArray

packages/effect/src/Channel.ts:684–688  ·  view source on GitHub ↗
(array: ReadonlyArray<A>)

Source from the content-addressed store, hash-verified

682 * @since 4.0.0
683 */
684export const fromArray = <A>(array: ReadonlyArray<A>): Channel<A> =>
685 fromPull(Effect.sync(() => {
686 let index = 0
687 return Effect.suspend(() => index >= array.length ? Cause.done() : Effect.succeed(array[index++]))
688 }))
689
690/**
691 * Creates a `Channel` that emits all elements from a chunk.

Callers 1

fromChunkFunction · 0.70

Calls 4

fromPullFunction · 0.70
syncMethod · 0.45
doneMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected