gossamer/set
JavaScript Set bindings for interop with APIs that produce or
consume a Set. Treated as a transit type: bridge to
gleam/set.Set
via to_set and operate on the canonical Gleam surface
for transformations, then from_set back when handing
off to JavaScript. The non-mutating reads (size,
has, values) stay for one-shot interop
without round-tripping through gleam/set.Set.
Types
A JavaScript Set, holding unique values of any type and preserving
insertion order.
For most Gleam use cases, prefer gleam/set.Set. This binding exists
for interop with JavaScript code that expects a Set; bridge with
to_set / from_set and operate on the gleam/set.Set surface for
transformations.
Object values (records, lists, tuples) are matched by JavaScript
reference identity, not by Gleam value equality — two equal-by-value
tuples constructed separately are distinct values. Primitive values
(Int, Float, String, Bool) use value equality.
See Set on MDN.
pub type Set(value)
Values
pub fn from_list(values: List(value)) -> Set(value)
Creates a Set from a list of values. Duplicate values appear once.
pub fn has(in values: Set(value), value value: value) -> Bool
Returns whether the Set contains the given value.
pub fn to_set(values: Set(value)) -> set.Set(value)
Converts the Set to a gleam/set.Set. Insertion order is
preserved as gleam/set.Set insertion order.
pub fn values(values: Set(value)) -> yielder.Yielder(value)
Returns the values of the Set in insertion order.