Hyperlinkv0.8.0-beta.28

TxHashSet

TxHashSet.sizeconsteffect/TxHashSet.ts:452
<V>(self: TxHashSet<V>): Effect.Effect<number>

Returns the number of values in the TxHashSet.

Example (Getting the set size)

import { Effect, TxHashSet } from "effect"

const program = Effect.gen(function*() {
  const empty = yield* TxHashSet.empty<string>()
  console.log(yield* TxHashSet.size(empty)) // 0

  const small = yield* TxHashSet.make("a", "b")
  console.log(yield* TxHashSet.size(small)) // 2

  const fromIterable = yield* TxHashSet.fromIterable(["x", "y", "z", "x", "y"])
  console.log(yield* TxHashSet.size(fromIterable)) // 3 (duplicates ignored)
})
getters
export const size = <V>(self: TxHashSet<V>): Effect.Effect<number> =>
  Effect.gen(function*() {
    const set = yield* TxRef.get(self.ref)
    return HashSet.size(set)
  })