Skip to main content

StaticJsIterator

A sandboxed iterator value.

Import

import { type StaticJsIterator, isStaticJsIterator } from "@suntime-js/core";

Extends​

StaticJsObject → StaticJsPrimitive


Overview​

StaticJsIterator represents any iterator object inside the sandbox — the result of calling [Symbol.iterator]() on a collection, iterating a sandboxed map or set, or consuming a generator's iterator interface. It exposes a single next operation in three variants following the same triplet pattern used by StaticJsObject.


Properties​

Inherits all properties from StaticJsObject.

typeOf​

"object"

runtimeTypeOf​

"iterator"


Methods​

Inherits all methods from StaticJsObject.

next(opts?)​

nextSync(opts?: StaticJsRunTaskOptions): StaticJsIteratorResult
nextAsync(opts?: StaticJsRunTaskOptions): Promise<StaticJsIteratorResult>
nextEvaluator(): EvaluationGenerator<StaticJsIteratorResult>

Advances the iterator one step. Returns a StaticJsIteratorResult containing the yielded sandbox value and a done flag indicating whether the iterator is exhausted.

Use nextAsync in general host code, nextSync when synchronous completion is required (ensure a time-bounded runTaskSync is configured), and nextEvaluator inside evaluator functions. The *Sync and *Async variants accept an optional StaticJsRunTaskOptions to override the task runner; the *Evaluator variant does not.


Types​

StaticJsIteratorResult​

import { type StaticJsIteratorResult } from "@suntime-js/core";

interface StaticJsIteratorResult {
readonly value: StaticJsValue;
readonly done: boolean;
}

The result record returned by next*. value is the yielded sandbox value for this step; done is true when the iterator is exhausted and value is the final return value (or StaticJsUndefined if none).


Type guard​

isStaticJsIterator(value)​

isStaticJsIterator(value: unknown): value is StaticJsIterator