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()callsinitialize()on the first invocation, then delegates tohandleNext().- When
handleNext()returns{ done: true },dispose()is called then the enumerator marks itself completed. doneWithYield(value)emits one final element, callsdispose(), then marks completed.earlyComplete()callsdispose()and marks completed without yielding.return()triggers early termination: callsdispose()then marks completed. Idempotent.- Once completed, all
next()calls return{ done: true }without re-invokinghandleNext().
Subclasses must implement handleNext(). Override initialize(), disposeSource(), and disposeAdditional() as needed.
Extended by
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TInput | - | Source element type. |
TOutput | TInput | Output element type (defaults to TInput). |
Implements
Enumerator<TOutput>
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
return()
return(
value?):IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:54
Terminates iteration early, disposes resources, and marks completed. Idempotent.
Parameters
| Parameter | Type |
|---|---|
value? | unknown |
Returns
IteratorResult<TOutput>
Implementation of
initialize()
protectedinitialize():void
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:64
Called once before the first handleNext() invocation. Override to set up state.
Returns
void
yield()
protectedyield(value):IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:67
Wraps value in a non-done IteratorResult.
Parameters
| Parameter | Type |
|---|---|
value | TOutput |
Returns
IteratorResult<TOutput>
done()
protecteddone():IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:72
Returns a done IteratorResult.
Returns
IteratorResult<TOutput>
doneWithYield()
protecteddoneWithYield(value):IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:82
Marks the enumerator completed and yields value as the final element.
Parameters
| Parameter | Type |
|---|---|
value | TOutput |
Returns
IteratorResult<TOutput>
Remarks
Use when the last element must be emitted together with completion in one step.
earlyComplete()
protectedearlyComplete(reason?):IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:94
Disposes resources, marks completed, and returns a done result.
Parameters
| Parameter | Type |
|---|---|
reason? | unknown |
Returns
IteratorResult<TOutput>
Remarks
Use inside handleNext() to terminate iteration before the source is exhausted.
dispose()
protecteddispose(value?):void
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:101
Calls disposeSource() then disposeAdditional().
Parameters
| Parameter | Type |
|---|---|
value? | unknown |
Returns
void
disposeSource()
protecteddisposeSource():void
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:107
Override to dispose the upstream source enumerator.
Returns
void
disposeAdditional()
protecteddisposeAdditional(_value?):void
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:116
Override to release any additional resources.
Parameters
| Parameter | Type |
|---|---|
_value? | unknown |
Returns
void
Remarks
Called after disposeSource(). value is the return value passed to return(). Must be idempotent and must not throw.
handleNext()
abstractprotectedhandleNext():IteratorResult<TOutput>
Defined in: src/core/enumerators/TyneqBaseEnumerator.ts:119
Produces the next element. Return { done: true } to signal exhaustion.
Returns
IteratorResult<TOutput>