Interface JsIterator

All Superinterfaces:
Iterator<Object>

public interface JsIterator extends Iterator<Object>
Spec-style values iterator returned by IterUtils.getIterator(java.lang.Object, io.karatelabs.js.Context). Used by for-of, spread, destructuring, and Array.from — the call sites that require ECMAScript GetIterator semantics (TypeError on non-iterable, value-only enumeration, no key channel).
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    close(Context context, boolean dueToError)
    IteratorClose (spec 7.4.6): invoke the iterator's return method when iteration ends before the iterator is exhausted (destructuring with no rest element, for-of break/return/throw).

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • Method Details

    • close

      default void close(Context context, boolean dueToError)
      IteratorClose (spec 7.4.6): invoke the iterator's return method when iteration ends before the iterator is exhausted (destructuring with no rest element, for-of break/return/throw). The internal array / string iterators have no observable return, so the default is a no-op; only user-defined iterators (objects with Symbol.iterator) override it.

      dueToError mirrors the spec's completion argument: when true the surrounding completion is already abrupt, so return's own result and any error it raises are discarded (the original completion wins). When false a return that throws propagates, and a non-object return result is a TypeError.