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

Function fromArray

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

Source from the content-addressed store, hash-verified

748 * @since 4.0.0
749 */
750export const fromArray = <A>(array: ReadonlyArray<A>): Channel<A> =>
751 fromPull(Effect.sync(() => {
752 let index = 0
753 return Effect.suspend(() => index >= array.length ? Cause.done() : Effect.succeed(array[index++]))
754 }))
755
756/**
757 * 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