effect-io-ai

Package: effect
Module: TxHashSet

TxHashSet.add

Adds a value to the TxHashSet. If the value already exists, the operation has no effect.

Details

This function mutates the original TxHashSet by adding the specified value. It does not return a new TxHashSet reference.

Example (Adding values)

import { Effect, TxHashSet } from "effect"

const program = Effect.gen(function*() {
  const txSet = yield* TxHashSet.make("a", "b")

  yield* TxHashSet.add(txSet, "c")
  console.log(yield* TxHashSet.size(txSet)) // 3
  console.log(yield* TxHashSet.has(txSet, "c")) // true

  // Adding existing value has no effect
  yield* TxHashSet.add(txSet, "a")
  console.log(yield* TxHashSet.size(txSet)) // 3 (unchanged)
})

Signature

declare const add: { <V>(value: V): (self: TxHashSet<V>) => Effect.Effect<void>; <V>(self: TxHashSet<V>, value: V): Effect.Effect<void>; }

Source

Since v2.0.0