import * as tsplus_module_1 from "@effect/core/stm/STM/operations/succeed";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/flatMap";
import * as tsplus_module_3 from "@effect/core/stm/STM/operations/succeedNow";
/**
 * Determines whether all elements of the `Collection<A>` satisfies the effectual
 * predicate `f`.
 *
 * @tsplus static ets/STM/Ops forAll
 */

export function forAll(as, f) {
  return tsplus_module_2.flatMap_(tsplus_module_1.succeed(as), Collection => loop(Collection[Symbol.iterator](), f));
}

function loop(iterator, f) {
  const next = iterator.next();
  return next.done ? tsplus_module_3.succeedNow(true) : tsplus_module_2.flatMap_(f(next.value), b => b ? loop(iterator, f) : tsplus_module_3.succeedNow(b));
}
//# sourceMappingURL=forAll.mjs.map