/** * Atomically folds using a transactional function. * * @tsplus static effect/core/stm/TMap.Aspects foldSTM * @tsplus pipeable effect/core/stm/TMap foldSTM */ export function foldSTM( zero: A, op: (a: A, kv: readonly [K, V]) => STM ) { return (self: TMap): STM => self.toChunk.flatMap((_) => STM.reduce(_, zero, op)) }