Skip to content

Commit

Permalink
minor implementation cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Dec 3, 2024
1 parent 8104939 commit 5731124
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
function concatImpl(): Iterator<never>
function concatImpl<A>(...iterables: Array<Iterable<A>>): Iterator<A>
function concatImpl<A>(iterableA: Iterable<A>): Iterator<A>
function concatImpl<A, B>(iterableA: Iterable<A>, iterableB: Iterable<B>): Iterator<A | B>
function concatImpl<A, B, C>(iterableA: Iterable<A>, iterableB: Iterable<B>, iterableC: Iterable<C>): Iterator<A | B | C>
function concatImpl<A, B, C, D>(iterableA: Iterable<A>, iterableB: Iterable<B>, iterableC: Iterable<C>, iterableD: Iterable<D>): Iterator<A | B | C | D>
function concatImpl<A, B, C, D, E>(iterableA: Iterable<A>, iterableB: Iterable<B>, iterableC: Iterable<C>, iterableD: Iterable<D>, iterableE: Iterable<E>): Iterator<A | B | C | D | E>
function concatImpl<T extends Iterable<unknown>[]>(...iterables: T): Iterator<T[number] extends Iterable<infer U> ? U : never, undefined, void>;
function concatImpl(...iterables: Array<Iterable<unknown>>): Iterator<unknown>
function concatImpl(...iterables: Array<unknown>): Iterator<unknown> {
const openMethods: Array<{ openMethod: () => Iterator<unknown>, iterable: Iterable<unknown>}> = [];
Expand All @@ -21,8 +16,8 @@ function concatImpl(...iterables: Array<unknown>): Iterator<unknown> {
return Iterator.from({
next() {
while (!done) {
if (iterator != null && nextMethod != null) {
let iterResult = nextMethod.call(iterator);
if (iterator != null) {
let iterResult = nextMethod!.call(iterator);
if (!iterResult.done) {
return iterResult;
}
Expand All @@ -48,7 +43,7 @@ function concatImpl(...iterables: Array<unknown>): Iterator<unknown> {
}
done = true;
}
return { done: true, value: void 0, };
return { done: true, value: void 0 };
},
});
}
Expand Down

0 comments on commit 5731124

Please sign in to comment.