Hyperlinkv0.8.0-beta.28

TxHashSet

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

Checks whether at least one value in the TxHashSet satisfies the predicate.

Example (Testing whether some values match)

import { Effect, TxHashSet } from "effect"

const program = Effect.gen(function*() {
  const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5)

  console.log(yield* TxHashSet.some(numbers, (n) => n > 3)) // true
  console.log(yield* TxHashSet.some(numbers, (n) => n > 10)) // false

  const empty = yield* TxHashSet.empty<number>()
  console.log(yield* TxHashSet.some(empty, (n) => n > 0)) // false
})
elements
export const some: {
  <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.some(set, predicate)
  }))