// ets_tracing: off import type { NonEmptyArray } from "../Collections/Immutable/NonEmptyArray/index.js" import type * as Tp from "../Collections/Immutable/Tuple/index.js" import type { _A, _E, _R, ForcedArray } from "../Utils/index.js" import type { Effect } from "./effect.js" import { map_ } from "./map.js" import { tuple, tuplePar, tupleParN } from "./tuple.js" /** * Sequentially zips the specified effects using the specified combiner * function. * * @ets_data_first mapN_ */ export function mapN>, B>( f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): (t: Tp.Tuple) => Effect<_R, _E, B> { return (t) => mapN_(t, f, __trace) } /** * Sequentially zips the specified effects using the specified combiner * function. */ export function mapN_>, B>( t: Tp.Tuple, f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): Effect<_R, _E, B> { // @ts-expect-error return map_(tuple(...t.tuple), (x) => f(...x.tuple), __trace) } /** * Zips the specified effects in parallel using the specified combiner * function. * * @ets_data_first mapNPar_ */ export function mapNPar>, B>( f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): (t: Tp.Tuple) => Effect<_R, _E, B> { return (t) => mapNPar_(t, f, __trace) } /** * Zips the specified effects in parallel using the specified combiner * function. */ export function mapNPar_>, B>( t: Tp.Tuple, f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): Effect<_R, _E, B> { // @ts-expect-error return map_(tuplePar(...t.tuple), (x) => f(...x.tuple), __trace) } /** * Zips the specified effects in parallel using the specified combiner * function. * * This variant uses up to N fibers. */ export function mapNParN>, B>( n: number, f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): (t: Tp.Tuple) => Effect<_R, _E, B> { return (t) => mapNParN_(t, n, f, __trace) } /** * Zips the specified effects in parallel using the specified combiner * function. * * This variant uses up to N fibers. */ export function mapNParN_>, B>( t: Tp.Tuple, n: number, f: (..._: ForcedArray<{ [k in keyof T]: _A }>) => B, __trace?: string ): Effect<_R, _E, B> { // @ts-expect-error return map_(tupleParN(n)(...t.tuple), (x) => f(...x.tuple), __trace) }