generated from T99/ts-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a glaring bug where the underlying
Symbol.iterator
implementa…
…tion was removed.
- Loading branch information
Trevor Sears
committed
Sep 10, 2021
1 parent
dec4b3c
commit a07e927
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ import { Iterable } from "./iterable"; | |
* exhausted. Can be set to 'void' in the case that this AbstractIterable has infinite content. Defaults to `undefined`. | ||
* | ||
* @author Trevor Sears <[email protected]> | ||
* @version v1.0.0 | ||
* @version v1.1.0 | ||
* @since v0.1.0 | ||
*/ | ||
export abstract class AbstractIterable<E, U = undefined> implements Iterable<E, U> { | ||
|
@@ -53,7 +53,34 @@ export abstract class AbstractIterable<E, U = undefined> implements Iterable<E, | |
*/ | ||
public [Symbol.iterator](): IterableIterator<E> { | ||
|
||
return this.iterator()[Symbol.iterator](); | ||
return new class implements IterableIterator<E> { | ||
|
||
private iterator: Iterator<E, U>; | ||
|
||
public constructor(iterable: Iterable<E, U>) { | ||
|
||
this.iterator = iterable.iterator(); | ||
|
||
} | ||
|
||
public [Symbol.iterator](): IterableIterator<E> { | ||
|
||
return this; | ||
|
||
} | ||
|
||
public next(): IteratorResult<E> { | ||
|
||
return { | ||
|
||
done: !this.iterator.hasNext(), | ||
value: this.iterator.next() as E | ||
|
||
}; | ||
|
||
} | ||
|
||
}(this); | ||
|
||
} | ||
|
||
|