effect-io-ai

Package: effect
Module: TxHashSet

TxHashSet.remove

Removes a value from the TxHashSet.

Details

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

Example (Removing values)

import { Effect, TxHashSet } from "effect"

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

  const removed = yield* TxHashSet.remove(txSet, "b")
  console.log(removed) // true (value existed and was removed)
  console.log(yield* TxHashSet.size(txSet)) // 2
  console.log(yield* TxHashSet.has(txSet, "b")) // false

  // Removing non-existent value returns false
  const notRemoved = yield* TxHashSet.remove(txSet, "d")
  console.log(notRemoved) // false
})

Signature

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

Source

Since v2.0.0