effect-io-ai

Package: effect
Module: TxHashSet

TxHashSet.every

Checks whether all values in the TxHashSet satisfy the predicate.

Example (Testing whether every value matches)

import { Effect, TxHashSet } from "effect"

const program = Effect.gen(function*() {
  const numbers = yield* TxHashSet.make(2, 4, 6, 8)

  console.log(yield* TxHashSet.every(numbers, (n) => n % 2 === 0)) // true
  console.log(yield* TxHashSet.every(numbers, (n) => n > 5)) // false

  const empty = yield* TxHashSet.empty<number>()
  console.log(yield* TxHashSet.every(empty, (n) => n > 0)) // true (vacuously true)
})

Signature

declare const every: { <V>(predicate: Predicate<V>): (self: TxHashSet<V>) => Effect.Effect<boolean>; <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<boolean>; }

Source

Since v4.0.0