iter wrapper

This commit is contained in:
ari committed 2021-11-30 16:54:36 -05:00
1 parent 60b522922a
commit 8ff9f29ac0
2 files changed
+44

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export class IteratorWrap<T, TReturn, TNext> {
public returnValue: TReturn | null = null;
constructor(
private it: Generator<T,TReturn,TNext>
) { }
*iter() {
let next = this.it.next()
while (!next.done) {
yield next.value
next = this.it.next()
}
this.returnValue = next.value
}
toArray() {
return Array.from(this.iter())
}
}