// ets_tracing: off import { chain_, succeed, yieldNow } from "./core.js" import type { Effect } from "./effect.js" import { zipRight_ } from "./zips.js" /** * Repeats this effect the specified number of times. * * @ets_data_first repeatN_ */ export function repeatN(n: number, __trace?: string) { return (self: Effect): Effect => repeatN_(self, n, __trace) } /** * Repeats this effect the specified number of times. */ export function repeatN_( self: Effect, n: number, __trace?: string ): Effect { return chain_( self, (a) => (n <= 0 ? succeed(a) : zipRight_(yieldNow, repeatN_(self, n - 1))), __trace ) }