Provides a Svelte 4 Readable store based Set implementation.

Note: This implementation will be removed in transition to Svelte 5.

Type Parameters

  • T
Implements
Hierarchy

Constructors

Methods

  • Appends a new element with a specified value to the end of the Set.

    Parameters

    • value: T

      Value to add.

    Returns this

    This instance.

  • Clears this set.

    Returns void

  • Removes a specified value from the Set.

    Parameters

    • value: T

      Value to delete.

    Returns boolean

    Returns true if an element in the Set existed and has been removed, or false if the element does not exist.

  • Return the difference of two sets.

    Parameters

    • other: Set<T>

      Some other set to compare against

    Returns Set<T>

    The difference defined as objects in this which are not present in other

  • Type Parameters

    • U

    Parameters

    Returns Set<T | U>

  • Returns an iterable of [v,v] pairs for every value v in the set.

    Returns SetIterator<[T, T]>

  • Test whether this set is equal to some other set. Sets are equal if they share the same members, independent of order

    Parameters

    • other: Set<unknown>

      Some other set to compare against

    Returns boolean

    Are the sets equal?

  • Test whether every element in this Set satisfies a certain test criterion.

    Type Parameters

    • U = T

    Parameters

    • test: (value: T, index: number, set: Set<T>) => value is U

      The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being tested.

    Returns this is Set<U>

    Does every element in the set satisfy the test criterion?

    Array#every

  • Parameters

    • test: (value: T, index: number, set: Set<T>) => boolean

    Returns boolean

  • Filter this set to create a subset of elements which satisfy a certain test criterion.

    Type Parameters

    • U = T

    Parameters

    • test: (value: T, index: number, set: Set<T>) => value is U

      The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being filtered.

    Returns Set<U>

    A new Set containing only elements which satisfy the test criterion.

    Array#filter

  • Parameters

    • test: (value: T, index: number, set: Set<T>) => boolean

    Returns Set<T>

  • Find the first element in this set which satisfies a certain test criterion.

    Type Parameters

    • U = T

    Parameters

    • test: (value: T, index: number, obj: Set<T>) => value is U

      The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being searched.

    Returns U

    The first element in the set which satisfies the test criterion, or undefined.

    Array#find

  • Parameters

    • test: (value: T, index: number, obj: Set<T>) => boolean

    Returns T

  • Return the first value from the set.

    Returns T

    The first element in the set, or undefined

  • Executes a provided function once per each value in the Set object, in insertion order.

    Parameters

    • callbackfn: (value: T, value2: T, set: Set<T>) => void
    • OptionalthisArg: any

    Returns void

  • Parameters

    • value: T

    Returns boolean

    a boolean indicating whether an element with the specified value exists in the Set or not.

  • Return the intersection of two sets.

    Parameters

    • other: Set<T>

      Some other set to compare against

    Returns Set<T>

    The intersection of both sets

  • Type Parameters

    • U

    Parameters

    Returns Set<T | U>

  • Test whether this set has an intersection with another set.

    Parameters

    • other: Set<unknown>

      Another set to compare against

    Returns boolean

    Do the sets intersect?

  • Test whether this set is a subset of some other set. A set is a subset if all its members are also present in the other set.

    Parameters

    • other: Set<unknown>

      Some other set that may be a subset of this one

    Returns boolean

    Is the other set a subset of this one?

  • Despite its name, returns an iterable of the values in the set.

    Returns SetIterator<T>

  • Create a new Set where every element is modified by a provided transformation function.

    Type Parameters

    • U

    Parameters

    • transform: (value: T, index: number, set: Set<T>) => U

      The transformation function to apply.Positional arguments are the value, the index of iteration, and the set being transformed.

    Returns Set<U>

    A new Set of equal size containing transformed elements.

    Array#map

  • Create a new Set with elements that are filtered and transformed by a provided reducer function.

    Type Parameters

    • U

    Parameters

    • reducer: (previousValue: U, currentValue: T, currentIndex: number, set: Set<T>) => U

      A reducer function applied to each value. Positional arguments are the accumulator, the value, the index of iteration, and the set being reduced.

    • accumulator: U

      The initial value of the returned accumulator.

    Returns U

    The final value of the accumulator.

    Array#reduce

  • Parameters

    • reducer: (previousValue: T, currentValue: T, currentIndex: number, set: Set<T>) => T
    • accumulator: T

    Returns T

  • Test whether any element in this Set satisfies a certain test criterion.

    Parameters

    • test: (value: T, index: number, set: Set<T>) => boolean

      The test criterion to apply. Positional arguments are the value, the index of iteration, and the set being tested.

    Returns boolean

    Does any element in the set satisfy the test criterion?

    Array#some

  • Return the symmetric difference of two sets.

    Parameters

    • other: Set<T>

      Another set.

    Returns Set<T>

    The set of elements that exist in this or other, but not both.

  • Type Parameters

    • U

    Parameters

    Returns Set<T | U>

  • Convert a set to a JSON object by mapping its contents to an array

    Returns T[]

    The set elements as an array.

  • Return the union of two sets.

    Parameters

    • other: Set<T>

      The other set.

    Returns Set<T>

  • Type Parameters

    • U

    Parameters

    Returns Set<T | U>

Properties

"[toStringTag]": string
size: number

the number of (unique) elements in Set.

"[species]": SetConstructor