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

Function forEachParN

packages/effect/src/internal/fiberRuntime.ts:2415–2426  ·  view source on GitHub ↗
(
  self: Iterable<A>,
  n: number,
  f: (a: A, i: number) => Effect.Effect<B, E, R>,
  batching: boolean
)

Source from the content-addressed store, hash-verified

2413
2414/* @internal */
2415export const forEachParN = <A, B, E, R>(
2416 self: Iterable<A>,
2417 n: number,
2418 f: (a: A, i: number) => Effect.Effect<B, E, R>,
2419 batching: boolean
2420): Effect.Effect<Array<B>, E, R> =>
2421 core.suspend(() => {
2422 const as = RA.fromIterable(self)
2423 const array = new Array<B>(as.length)
2424 const fn = (a: A, i: number) => core.map(f(a, i), (b) => array[i] = b)
2425 return core.zipRight(forEachConcurrentDiscard(as, fn, batching, false, n), core.succeed(array))
2426 })
2427
2428/* @internal */
2429export const fork = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<Fiber.RuntimeFiber<A, E>, never, R> =>

Callers 2

fiberRuntime.tsFile · 0.85
closeFunction · 0.85

Calls 1

forEachConcurrentDiscardFunction · 0.85

Tested by

no test coverage detected