DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Overview
Stdlib
submodules
  • Array
  • ArrayBuffer
  • AsyncIterator
  • BigInt
  • BigInt64Array
    • Constants
    BigUint64Array
    • Constants
  • Bool
  • Console
  • DataView
  • Date
    • UTC
  • Dict
  • Error
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • Exn
  • Float
    • Constants
    Float32Array
    • Constants
    Float64Array
    • Constants
    Int
    • Ref
    • Bitwise
    • Constants
    Int16Array
    • Constants
    Int32Array
    • Constants
    Int8Array
    • Constants
  • IntervalId
  • Intl
    • Segments
    • Segmenter
    • RelativeTimeFormat
    • PluralRules
    • NumberFormat
      • Grouping
    • Locale
    • ListFormat
    • DateTimeFormat
    • Collator
    • Common
  • Iterator
  • JSON
    • Decode
    • Encode
    • Classify
    JsError
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • JsExn
  • Lazy
  • List
  • Map
  • Math
    • Int
    • Constants
  • Null
  • Nullable
  • Object
  • Option
  • Ordering
  • Pair
  • Promise
  • RegExp
    • Result
  • Result
  • Set
  • String
  • Symbol
  • TimeoutId
  • Type
    • Classify
  • TypedArray
  • Uint16Array
    • Constants
    Uint32Array
    • Constants
    Uint8Array
    • Constants
    Uint8ClampedArray
    • Constants
  • WeakMap
  • WeakSet
    • t
      t
    • v
      make
    • v
      add
    • v
      delete
    • v
      has
    • v
      ignore
  • Docs / API / Stdlib / Weakset

    WeakSet

    Bindings to JavaScript's WeakSet.

    Weak sets store references to objects without preventing those objects from being garbage collected.

    t

    RESCRIPT
    type t<'a>

    Mutable weak set storing object references of type 'a.

    make

    RESCRIPT
    let make: unit => t<'a>

    Creates an empty weak set.

    See WeakSet on MDN.

    Examples

    RESCRIPT
    let visited = WeakSet.make() WeakSet.has(visited, Object.make()) == false

    add

    RESCRIPT
    let add: (t<'a>, 'a) => t<'a>

    add(set, value) inserts value into the weak set and returns the set for chaining.

    See WeakSet.prototype.add on MDN.

    Examples

    RESCRIPT
    let set = WeakSet.make() let node = Object.make() WeakSet.add(set, node) WeakSet.has(set, node) == true

    delete

    RESCRIPT
    let delete: (t<'a>, 'a) => bool

    delete(set, value) removes value and returns true if an entry existed.

    See WeakSet.prototype.delete on MDN.

    Examples

    RESCRIPT
    let set = WeakSet.make() let node = Object.make() let _ = WeakSet.add(set, node) WeakSet.delete(set, node) == true WeakSet.delete(set, node) == false

    has

    RESCRIPT
    let has: (t<'a>, 'a) => bool

    has(set, value) checks whether value exists in the weak set.

    See WeakSet.prototype.has on MDN.

    Examples

    RESCRIPT
    let set = WeakSet.make() let node = Object.make() WeakSet.has(set, node) == false let _ = WeakSet.add(set, node) WeakSet.has(set, node) == true

    ignore

    RESCRIPT
    let ignore: t<'a> => unit

    ignore(weakSet) ignores the provided weakSet and returns unit.

    This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.

    Types and values
    • t
      t
    • v
      make
    • v
      add
    • v
      delete
    • v
      has
    • v
      ignore

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on