Skip to content

tyneq


tyneq / TyneqBaseEnumerator

Abstract Class: TyneqBaseEnumerator<TInput, TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:22

Abstract base class implementing the pull-iterator lifecycle for all Tyneq enumerators.

Remarks

State machine:

  • next() calls initialize() on the first invocation, then delegates to handleNext().
  • When handleNext() returns { done: true }, dispose() is called then the enumerator marks itself completed.
  • doneWithYield(value) emits one final element, calls dispose(), then marks completed.
  • earlyComplete() calls dispose() and marks completed without yielding.
  • return() triggers early termination: calls dispose() then marks completed. Idempotent.
  • Once completed, all next() calls return { done: true } without re-invoking handleNext().

Subclasses must implement handleNext(). Override initialize(), disposeSource(), and disposeAdditional() as needed.

Extended by

Type Parameters

Type ParameterDefault typeDescription
TInput-Source element type.
TOutputTInputOutput element type (defaults to TInput).

Implements

Constructors

Constructor

new TyneqBaseEnumerator<TInput, TOutput>(): TyneqBaseEnumerator<TInput, TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:26

Returns

TyneqBaseEnumerator<TInput, TOutput>

Methods

next()

next(): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:29

Advances the iterator, calling initialize() on first call. Idempotent after completion.

Returns

IteratorResult<TOutput>

Implementation of

Enumerator.next


return()

return(value?): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:54

Terminates iteration early, disposes resources, and marks completed. Idempotent.

Parameters

ParameterType
value?unknown

Returns

IteratorResult<TOutput>

Implementation of

Enumerator.return


initialize()

protected initialize(): void

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:64

Called once before the first handleNext() invocation. Override to set up state.

Returns

void


yield()

protected yield(value): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:67

Wraps value in a non-done IteratorResult.

Parameters

ParameterType
valueTOutput

Returns

IteratorResult<TOutput>


done()

protected done(): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:72

Returns a done IteratorResult.

Returns

IteratorResult<TOutput>


doneWithYield()

protected doneWithYield(value): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:82

Marks the enumerator completed and yields value as the final element.

Parameters

ParameterType
valueTOutput

Returns

IteratorResult<TOutput>

Remarks

Use when the last element must be emitted together with completion in one step.


earlyComplete()

protected earlyComplete(reason?): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:94

Disposes resources, marks completed, and returns a done result.

Parameters

ParameterType
reason?unknown

Returns

IteratorResult<TOutput>

Remarks

Use inside handleNext() to terminate iteration before the source is exhausted.


dispose()

protected dispose(value?): void

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:101

Calls disposeSource() then disposeAdditional().

Parameters

ParameterType
value?unknown

Returns

void


disposeSource()

protected disposeSource(): void

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:107

Override to dispose the upstream source enumerator.

Returns

void


disposeAdditional()

protected disposeAdditional(_value?): void

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:116

Override to release any additional resources.

Parameters

ParameterType
_value?unknown

Returns

void

Remarks

Called after disposeSource(). value is the return value passed to return(). Must be idempotent and must not throw.


handleNext()

abstract protected handleNext(): IteratorResult<TOutput>

Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:119

Produces the next element. Return { done: true } to signal exhaustion.

Returns

IteratorResult<TOutput>