MCPcopy Index your code
hub / github.com/Effect-TS/effect / fromAsyncIterable

Function fromAsyncIterable

packages/effect/src/internal/stream.ts:2975–2994  ·  view source on GitHub ↗
(
  iterable: AsyncIterable<A>,
  onError: (e: unknown) => E
)

Source from the content-addressed store, hash-verified

2973
2974/** @internal */
2975export const fromAsyncIterable = <A, E>(
2976 iterable: AsyncIterable<A>,
2977 onError: (e: unknown) => E
2978) =>
2979 pipe(
2980 Effect.acquireRelease(
2981 Effect.sync(() => iterable[Symbol.asyncIterator]()),
2982 (iterator) => iterator.return ? Effect.promise(async () => iterator.return!()) : Effect.void
2983 ),
2984 Effect.map((iterator) =>
2985 repeatEffectOption(pipe(
2986 Effect.tryPromise({
2987 try: async () => iterator.next(),
2988 catch: (reason) => Option.some(onError(reason))
2989 }),
2990 Effect.flatMap((result) => result.done ? Effect.fail(Option.none()) : Effect.succeed(result.value))
2991 ))
2992 ),
2993 unwrapScoped
2994 )
2995
2996/** @internal */
2997export const fromChannel = <A, E, R>(

Callers

nothing calls this directly

Calls 7

repeatEffectOptionFunction · 0.85
syncMethod · 0.80
pipeFunction · 0.70
mapMethod · 0.65
nextMethod · 0.65
failMethod · 0.65
onErrorFunction · 0.50

Tested by

no test coverage detected