fix Iterator.next methods

This commit is contained in:
Rowan 2025-05-01 16:27:42 -05:00
parent 803c2bf162
commit c4e96e6cf6

View file

@ -88,8 +88,8 @@ export class IteratorEnumerator<T> implements IEnumerator<T>, Iterator<T> {
} }
next(...[_value]: [] | [any]): IteratorResult<T> { next(...[_value]: [] | [any]): IteratorResult<T> {
const done = this.moveNext() const next = this.moveNext()
return { value: this.current, done } as IteratorResult<T> return { value: this.current, done: !next } as IteratorResult<T>
} }
return(value?: any): IteratorResult<T, any> { return(value?: any): IteratorResult<T, any> {
@ -141,8 +141,8 @@ export class CachedIteratorEnumerator<T> implements IEnumerator<T>, Iterator<T>
} }
next(...[_value]: [] | [any]): IteratorResult<T> { next(...[_value]: [] | [any]): IteratorResult<T> {
const done = this.moveNext() const next = this.moveNext()
return { value: this.current, done } as IteratorResult<T> return { value: this.current, done: !next } as IteratorResult<T>
} }
return?(value?: any): IteratorResult<T, any> { return?(value?: any): IteratorResult<T, any> {
@ -194,8 +194,8 @@ export class IterableEnumerator<T> implements IEnumerator<T>, Iterator<T> {
} }
next(...[_value]: [] | [any]): IteratorResult<T, any> { next(...[_value]: [] | [any]): IteratorResult<T, any> {
const done = !this.moveNext() const next = !this.moveNext()
return { value: this.current, done } as IteratorResult<T, any> return { value: this.current, done: !next } as IteratorResult<T, any>
} }
return?(value?: any): IteratorResult<T, any> { return?(value?: any): IteratorResult<T, any> {
@ -266,8 +266,8 @@ export class ArrayEnumerator<T> implements IEnumerator<T>, Iterator<T>, Iterable
} }
next(...[_value]: [] | [any]): IteratorResult<T, any> { next(...[_value]: [] | [any]): IteratorResult<T, any> {
const done = this.moveNext() const next = this.moveNext()
return { value: this.current, done } as IteratorResult<T> return { value: this.current, done: !next } as IteratorResult<T>
} }
return?(_value?: any): IteratorResult<T, any> { return?(_value?: any): IteratorResult<T, any> {
@ -329,9 +329,9 @@ export class Enumerator<T> implements IEnumerator<T>, Iterator<T> {
} }
next(...[_value]: [] | [any]): IteratorResult<T, any> { next(...[_value]: [] | [any]): IteratorResult<T, any> {
const done = this.moveNext() const next = this.moveNext()
return { value: this.current, done } as IteratorResult<T> return { value: this.current, done: !next } as IteratorResult<T>
} }
return?(_value?: any): IteratorResult<T, any> { return?(_value?: any): IteratorResult<T, any> {
@ -377,9 +377,9 @@ export class HelperEnumerator<T> implements IEnumerator<T>, Iterator<T> {
} }
next(...[_value]: [] | [any]): IteratorResult<T, any> { next(...[_value]: [] | [any]): IteratorResult<T, any> {
const done = this.moveNext() const next = this.moveNext()
return { value: this.current, done } as IteratorResult<T> return { value: this.current, done: !next } as IteratorResult<T>
} }
return?(_value?: any): IteratorResult<T, any> { return?(_value?: any): IteratorResult<T, any> {