/** * Applies the function `f` to each element of the `Collection` and * returns a transactional effect that produces a new `Chunk`. * * @tsplus static effect/core/stm/STM.Ops forEach */ export function forEach( as: Collection, f: (a: A) => STM ): STM> { return STM.suspend(() => { let stm = STM.succeed([]) as STM for (const a of as) { stm = stm.zipWith(f(a), (acc, b) => { acc.push(b) return acc }) } return stm.map(Chunk.from) }) }