Hyperlinkv0.8.0-beta.28

TxHashSet

TxHashSet.everyconsteffect/TxHashSet.ts:726
<V>(predicate: Predicate<V>): (
  self: TxHashSet<V>
) => Effect.Effect<boolean>
<V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<boolean>

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)
})
elements
export const every: {
  <V>(predicate: Predicate<V>): (self: TxHashSet<V>) => Effect.Effect<boolean>
  <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<boolean>
} = dual<
  <V>(predicate: Predicate<V>) => (self: TxHashSet<V>) => Effect.Effect<boolean>,
  <V>(self: TxHashSet<V>, predicate: Predicate<V>) => Effect.Effect<boolean>
>(2, <V>(self: TxHashSet<V>, predicate: Predicate<V>) =>
  Effect.gen(function*() {
    const set = yield* TxRef.get(self.ref)
    return HashSet.every(set, predicate)
  }))