effect-io-ai

Package: effect
Module: HashSet

HashSet.fromIterable

Creates a HashSet from an iterable collection of values.

Example (Creating a HashSet from an iterable)

import { HashSet } from "effect"

const fromArray = HashSet.fromIterable(["a", "b", "c", "b", "a"])
console.log(HashSet.size(fromArray)) // 3

const fromSet = HashSet.fromIterable(new Set([1, 2, 3]))
console.log(HashSet.size(fromSet)) // 3

const fromString = HashSet.fromIterable("hello")
console.log(Array.from(fromString)) // ["h", "e", "l", "o"]

Signature

declare const fromIterable: <V>(values: Iterable<V>) => HashSet<V>

Source

Since v2.0.0