Skip to content

Commit 1d3ae86

Browse files
committed
Iterator.fromIterableIterator
1 parent c6d5242 commit 1d3ae86

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/vs/base/common/iterator.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ export module Iterator {
5656
};
5757
}
5858

59+
export function fromIterableIterator<T>(it: IterableIterator<T>): Iterator<T> {
60+
return {
61+
next(): IteratorResult<T> {
62+
const result = it.next();
63+
64+
if (result.done) {
65+
return FIN;
66+
}
67+
68+
return { done: false, value: result.value };
69+
}
70+
};
71+
}
72+
5973
export function from<T>(elements: Iterator<T> | T[] | undefined): Iterator<T> {
6074
if (!elements) {
6175
return Iterator.empty();

0 commit comments

Comments
 (0)