Package: effect
Module: TxHashSet
Creates a TxHashSet from an existing HashSet.
Example (Creating a transactional hash set from a HashSet)
import { Effect, HashSet, TxHashSet } from "effect"
const program = Effect.gen(function*() {
const hashSet = HashSet.make("x", "y", "z")
const txSet = yield* TxHashSet.fromHashSet(hashSet)
console.log(yield* TxHashSet.size(txSet)) // 3
console.log(yield* TxHashSet.has(txSet, "y")) // true
// Original hashSet is unchanged when txSet is modified
yield* TxHashSet.add(txSet, "w")
console.log(HashSet.size(hashSet)) // 3 (original unchanged)
console.log(yield* TxHashSet.size(txSet)) // 4
})
Signature
declare const fromHashSet: <V>(hashSet: HashSet.HashSet<V>) => Effect.Effect<TxHashSet<V>>
Since v4.0.0