/** * Determines whether all elements of the `Collection` satisfies the effectual * predicate `f`. * * @tsplus static effect/core/stm/STM.Ops forAll */ export function forAll( as: Collection, f: (a: A) => STM ): STM { return STM.suspend(loop(as[Symbol.iterator](), f)) } function loop( iterator: Iterator, f: (a: A) => STM ): STM { const next = iterator.next() return next.done ? STM.succeed(true) : f(next.value).flatMap((b) => (b ? loop(iterator, f) : STM.succeed(b))) }