MCPcopy Create free account
hub / github.com/effect-app/libs / fromIteratorArray

Function fromIteratorArray

repos/effect/packages/effect/src/Channel.ts:735–760  ·  view source on GitHub ↗
(
  iterator: LazyArg<Iterator<A, L>>,
  chunkSize = DefaultChunkSize
)

Source from the content-addressed store, hash-verified

733 * }
734 *
735 * const channel = Channel.fromIteratorArray(() => numberIterator(), 2)
736 * Effect.runSync(Channel.runCollect(channel)) // => [[0, 1], [2]]
737 * ```
738 *
739 * **Example** (Batching generator output)
740 *
741 * ```ts import.meta.vitest
742 * import { Channel, Effect } from "effect"
743 *
744 * // Create channel from a generator function
745 * function* fibonacci(): Generator<number, void, unknown> {
746 * let a = 0, b = 1
747 * for (let i = 0; i < 5; i++) {
748 * yield a
749 * ;[a, b] = [b, a + b]
750 * }
751 * }
752 *
753 * const fibChannel = Channel.fromIteratorArray(() => fibonacci(), 3)
754 * Effect.runSync(Channel.runCollect(fibChannel)) // => [[0, 1, 1], [2, 3]]
755 * ```
756 *
757 * @category constructors
758 * @since 4.0.0
759 */
760export const fromIteratorArray = <A, L>(
761 iterator: LazyArg<Iterator<A, L>>,
762 chunkSize = DefaultChunkSize
763): Channel<Arr.NonEmptyReadonlyArray<A>, never, L> => {

Callers 1

fromIterableArrayFunction · 0.85

Calls 7

syncMethod · 0.80
doneMethod · 0.80
someMethod · 0.80
pushMethod · 0.80
fromPullFunction · 0.70
nextMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…