StaticJsSet
A sandboxed Set value.
Import
import { type StaticJsSet, isStaticJsSet } from "@suntime-js/core";
Extends
StaticJsObject → StaticJsPrimitive
Overview
StaticJsSet represents a Set object inside the sandbox, such as those created by new Set(...). It exposes the standard ECMAScript Set operations — including the ES2024 set-composition methods — as full triplets following the same triplet pattern used by StaticJsObject.
All *Sync and *Async variants accept an optional StaticJsRunTaskOptions as their last argument. *Evaluator variants do not.
Properties
Inherits all properties from StaticJsObject.
typeOf
"object"
runtimeTypeOf
"set"
Methods
Inherits all methods from StaticJsObject.
size(opts?)
sizeSync(opts?: StaticJsRunTaskOptions): number
sizeAsync(opts?: StaticJsRunTaskOptions): Promise<number>
sizeEvaluator(): EvaluationGenerator<number>
Returns the number of values in the set as a native number.
keys(opts?)
keysSync(opts?: StaticJsRunTaskOptions): StaticJsIterator
keysAsync(opts?: StaticJsRunTaskOptions): Promise<StaticJsIterator>
keysEvaluator(): EvaluationGenerator<StaticJsIterator>
Returns a StaticJsIterator over the set's values (identical to values — sets have no distinct keys).
values(opts?)
valuesSync(opts?: StaticJsRunTaskOptions): StaticJsIterator
valuesAsync(opts?: StaticJsRunTaskOptions): Promise<StaticJsIterator>
valuesEvaluator(): EvaluationGenerator<StaticJsIterator>
Returns a StaticJsIterator over the set's values in insertion order.
entries(opts?)
entriesSync(opts?: StaticJsRunTaskOptions): StaticJsIterator
entriesAsync(opts?: StaticJsRunTaskOptions): Promise<StaticJsIterator>
entriesEvaluator(): EvaluationGenerator<StaticJsIterator>
Returns a StaticJsIterator over [value, value] pairs in insertion order, matching the ECMAScript Set.prototype.entries() shape.
has(value, opts?)
hasSync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): boolean
hasAsync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<boolean>
hasEvaluator(value: StaticJsValue): EvaluationGenerator<boolean>
Returns true if value is present in the set. Value equality follows the ECMAScript SameValueZero algorithm.
addValue(value, opts?)
addValueSync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): void
addValueAsync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<void>
addValueEvaluator(value: StaticJsValue): EvaluationGenerator<void>
Adds value to the set. Has no effect if the value is already present.
deleteValue(value, opts?)
deleteValueSync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): boolean
deleteValueAsync(value: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<boolean>
deleteValueEvaluator(value: StaticJsValue): EvaluationGenerator<boolean>
Removes value from the set. Returns true if the value existed and was removed, false otherwise.
clear(opts?)
clearSync(opts?: StaticJsRunTaskOptions): void
clearAsync(opts?: StaticJsRunTaskOptions): Promise<void>
clearEvaluator(): EvaluationGenerator<void>
Removes all values from the set.
forEach(callback, thisArg?, opts?)
forEachSync(callback: StaticJsFunction, thisArg?: StaticJsValue, opts?: StaticJsRunTaskOptions): void
forEachAsync(callback: StaticJsFunction, thisArg?: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<void>
forEachEvaluator(callback: StaticJsFunction, thisArg?: StaticJsValue): EvaluationGenerator<void>
Calls callback once for each value in insertion order. callback receives (value, value, set) as sandbox arguments (the key and value are the same, per the ECMAScript spec). thisArg is bound as this inside the callback; defaults to StaticJsUndefined if omitted.
Set composition methods
The following methods implement the ES2024 set-composition proposals. Each accepts another set-like sandbox value and returns a new StaticJsSet (as a StaticJsValue).
difference(otherSet, opts?)
differenceSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): StaticJsValue
differenceAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<StaticJsValue>
differenceEvaluator(otherSet: StaticJsValue): EvaluationGenerator<StaticJsValue>
Returns a new set containing values in this set that are not in otherSet.
intersection(otherSet, opts?)
intersectionSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): StaticJsValue
intersectionAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<StaticJsValue>
intersectionEvaluator(otherSet: StaticJsValue): EvaluationGenerator<StaticJsValue>
Returns a new set containing only values present in both this set and otherSet.
symmetricDifference(otherSet, opts?)
symmetricDifferenceSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): StaticJsValue
symmetricDifferenceAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<StaticJsValue>
symmetricDifferenceEvaluator(otherSet: StaticJsValue): EvaluationGenerator<StaticJsValue>
Returns a new set containing values present in either this set or otherSet, but not both.
union(otherSet, opts?)
unionSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): StaticJsValue
unionAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<StaticJsValue>
unionEvaluator(otherSet: StaticJsValue): EvaluationGenerator<StaticJsValue>
Returns a new set containing all values from both this set and otherSet.
isDisjointFrom(otherSet, opts?)
isDisjointFromSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): boolean
isDisjointFromAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<boolean>
isDisjointFromEvaluator(otherSet: StaticJsValue): EvaluationGenerator<boolean>
Returns true if this set and otherSet share no common values.
isSubsetOf(otherSet, opts?)
isSubsetOfSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): boolean
isSubsetOfAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<boolean>
isSubsetOfEvaluator(otherSet: StaticJsValue): EvaluationGenerator<boolean>
Returns true if every value in this set is also in otherSet.
isSupersetOf(otherSet, opts?)
isSupersetOfSync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): boolean
isSupersetOfAsync(otherSet: StaticJsValue, opts?: StaticJsRunTaskOptions): Promise<boolean>
isSupersetOfEvaluator(otherSet: StaticJsValue): EvaluationGenerator<boolean>
Returns true if every value in otherSet is also in this set.
Type guard
isStaticJsSet(value)
isStaticJsSet(value: unknown): value is StaticJsSet
See also
StaticJsMap: the map counterpartStaticJsIterator: type returned byentries,keys,values