Skip to content

Commit

Permalink
feat(merge/concat): add typed overloads for merge/concat (#84)
Browse files Browse the repository at this point in the history
* feat(merge/concat): add typed overloads for merge/concat

* feat(merge/concat): adding ignore to overloads

* feat(merge/concat): fix build errors
  • Loading branch information
mattpodwysocki authored Oct 17, 2017
1 parent f47179c commit 752aa96
Show file tree
Hide file tree
Showing 16 changed files with 400 additions and 66 deletions.
52 changes: 52 additions & 0 deletions src/add/asynciterable-operators/concat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
import { AsyncIterableX } from '../../asynciterable';
import { concat } from '../../asynciterable/concat';

/* tslint:disable:max-line-length */
/**
* @ignore
*/
export function concatProto<T>(this: AsyncIterableX<T>): AsyncIterableX<T>;
/**
* @ignore
*/
export function concatProto<T, T2>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>
): AsyncIterableX<T | T2>;
/**
* @ignore
*/
export function concatProto<T, T2, T3>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>
): AsyncIterableX<T | T2 | T3>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>
): AsyncIterableX<T | T2 | T3 | T4>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4, T5>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>
): AsyncIterable<T | T2 | T3 | T4 | T5>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4, T5, T6>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>,
v6: AsyncIterable<T6>
): AsyncIterable<T | T2 | T3 | T4 | T5 | T6>;
/* tslint:enable:max-line-length */

/**
* @ignore
*/
Expand Down
2 changes: 1 addition & 1 deletion src/add/asynciterable-operators/concatall.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncIterableX } from '../../asynciterable';
import { concatAll } from '../../asynciterable/concat';
import { concatAll } from '../../asynciterable/concatall';

/**
* @ignore
Expand Down
52 changes: 52 additions & 0 deletions src/add/asynciterable-operators/merge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
import { AsyncIterableX } from '../../asynciterable';
import { merge } from '../../asynciterable/merge';

/* tslint:disable:max-line-length */
/**
* @ignore
*/
export function mergeProto<T>(this: AsyncIterableX<T>): AsyncIterableX<T>;
/**
* @ignore
*/
export function mergeProto<T, T2>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>
): AsyncIterableX<T | T2>;
/**
* @ignore
*/
export function mergeProto<T, T2, T3>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>
): AsyncIterableX<T | T2 | T3>;
/**
* @ignore
*/
export function mergeProto<T, T2, T3, T4>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>
): AsyncIterableX<T | T2 | T3 | T4>;
/**
* @ignore
*/
export function mergeProto<T, T2, T3, T4, T5>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>
): AsyncIterable<T | T2 | T3 | T4 | T5>;
/**
* @ignore
*/
export function mergeProto<T, T2, T3, T4, T5, T6>(
this: AsyncIterableX<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>,
v6: AsyncIterable<T6>
): AsyncIterable<T | T2 | T3 | T4 | T5 | T6>;
/* tslint:enable:max-line-length */

/**
* @ignore
*/
Expand Down
2 changes: 1 addition & 1 deletion src/add/asynciterable-operators/mergeall.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncIterableX } from '../../asynciterable';
import { mergeAll } from '../../asynciterable/merge';
import { mergeAll } from '../../asynciterable/mergeall';

/**
* @ignore
Expand Down
46 changes: 46 additions & 0 deletions src/add/iterable-operators/concat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
import { IterableX } from '../../iterable';
import { concat } from '../../iterable/concat';

/* tslint:disable:max-line-length */
/**
* @ignore
*/
export function concatProto<T>(this: IterableX<T>): IterableX<T>;
/**
* @ignore
*/
export function concatProto<T, T2>(this: IterableX<T>, v2: Iterable<T2>): IterableX<T | T2>;
export function concatProto<T, T2, T3>(
this: IterableX<T>,
v2: Iterable<T2>,
v3: Iterable<T3>
): IterableX<T | T2 | T3>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4>(
this: IterableX<T>,
v2: Iterable<T2>,
v3: Iterable<T3>,
v4: Iterable<T4>
): IterableX<T | T2 | T3 | T4>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4, T5>(
this: IterableX<T>,
v2: Iterable<T2>,
v3: Iterable<T3>,
v4: Iterable<T4>,
v5: Iterable<T5>
): Iterable<T | T2 | T3 | T4 | T5>;
/**
* @ignore
*/
export function concatProto<T, T2, T3, T4, T5, T6>(
this: IterableX<T>,
v2: Iterable<T2>,
v3: Iterable<T3>,
v4: Iterable<T4>,
v5: Iterable<T5>,
v6: Iterable<T6>
): Iterable<T | T2 | T3 | T4 | T5 | T6>;
/* tslint:enable:max-line-length */

/**
* @ignore
*/
Expand Down
2 changes: 1 addition & 1 deletion src/add/iterable-operators/concatall.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IterableX } from '../../iterable';
import { concatAll } from '../../iterable/concat';
import { concatAll } from '../../iterable/concatall';

/**
* @ignore
Expand Down
4 changes: 2 additions & 2 deletions src/asynciterable/__modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { _catchStatic } from './catch';
import { catchWith } from './catchwith';
import { chain } from './chain';
import { concat } from './concat';
import { concatAll } from './concat';
import { concatAll } from './concatall';
import { concatStatic } from './concat';
import { count } from './count';
import { create } from './create';
Expand Down Expand Up @@ -59,7 +59,7 @@ import { max } from './max';
import { maxBy } from './maxby';
import { memoize } from './memoize';
import { merge } from './merge';
import { mergeAll } from './merge';
import { mergeAll } from './mergeall';
import { min } from './min';
import { minBy } from './minby';
import { of } from './of';
Expand Down
91 changes: 68 additions & 23 deletions src/asynciterable/concat.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import { AsyncIterableX } from '../asynciterable';

class ConcatAllAsyncIterable<TSource> extends AsyncIterableX<TSource> {
private _source: AsyncIterable<AsyncIterable<TSource>>;

constructor(source: AsyncIterable<AsyncIterable<TSource>>) {
super();
this._source = source;
}

async *[Symbol.asyncIterator]() {
for await (let outer of this._source) {
for await (let item of outer) {
yield item;
}
}
}
}

class ConcatAsyncIterable<TSource> extends AsyncIterableX<TSource> {
private _source: Iterable<AsyncIterable<TSource>>;

Expand All @@ -34,25 +17,87 @@ class ConcatAsyncIterable<TSource> extends AsyncIterableX<TSource> {
}
}

export function concatAll<TSource>(
source: AsyncIterable<AsyncIterable<TSource>>
): AsyncIterableX<TSource> {
return new ConcatAllAsyncIterable<TSource>(source);
}

export function _concatAll<TSource>(
source: Iterable<AsyncIterable<TSource>>
): AsyncIterableX<TSource> {
return new ConcatAsyncIterable<TSource>(source);
}

/* tslint:disable:max-line-length */
export function concat<T>(source: AsyncIterable<T>): AsyncIterableX<T>;
export function concat<T, T2>(
source: AsyncIterable<T>,
v2: AsyncIterable<T2>
): AsyncIterableX<T | T2>;
export function concat<T, T2, T3>(
source: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>
): AsyncIterableX<T | T2 | T3>;
export function concat<T, T2, T3, T4>(
source: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>
): AsyncIterableX<T | T2 | T3 | T4>;
export function concat<T, T2, T3, T4, T5>(
source: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>
): AsyncIterable<T | T2 | T3 | T4 | T5>;
export function concat<T, T2, T3, T4, T5, T6>(
source: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>,
v6: AsyncIterable<T6>
): AsyncIterable<T | T2 | T3 | T4 | T5 | T6>;
/* tslint:enable:max-line-length */

export function concat<T>(
source: AsyncIterable<T>,
...args: AsyncIterable<T>[]
): AsyncIterableX<T> {
return new ConcatAsyncIterable<T>([source, ...args]);
}

/* tslint:disable:max-line-length */
export function concatStatic<T>(v1: AsyncIterable<T>): AsyncIterableX<T>;
export function concatStatic<T, T2>(
v1: AsyncIterable<T>,
v2: AsyncIterable<T2>
): AsyncIterableX<T | T2>;
export function concatStatic<T, T2, T3>(
v1: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>
): AsyncIterableX<T | T2 | T3>;
export function concatStatic<T, T2, T3, T4>(
v1: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>
): AsyncIterableX<T | T2 | T3 | T4>;
export function concatStatic<T, T2, T3, T4, T5>(
v1: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>
): AsyncIterable<T | T2 | T3 | T4 | T5>;
export function concatStatic<T, T2, T3, T4, T5, T6>(
v1: AsyncIterable<T>,
v2: AsyncIterable<T2>,
v3: AsyncIterable<T3>,
v4: AsyncIterable<T4>,
v5: AsyncIterable<T5>,
v6: AsyncIterable<T6>
): AsyncIterable<T | T2 | T3 | T4 | T5 | T6>;
/* tslint:enable:max-line-length */

export function concatStatic<T>(...args: AsyncIterable<T>[]): AsyncIterableX<T> {
return new ConcatAsyncIterable<T>(args);
}
24 changes: 24 additions & 0 deletions src/asynciterable/concatall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { AsyncIterableX } from '../asynciterable';

class ConcatAllAsyncIterable<TSource> extends AsyncIterableX<TSource> {
private _source: AsyncIterable<AsyncIterable<TSource>>;

constructor(source: AsyncIterable<AsyncIterable<TSource>>) {
super();
this._source = source;
}

async *[Symbol.asyncIterator]() {
for await (let outer of this._source) {
for await (let item of outer) {
yield item;
}
}
}
}

export function concatAll<TSource>(
source: AsyncIterable<AsyncIterable<TSource>>
): AsyncIterableX<TSource> {
return new ConcatAllAsyncIterable<TSource>(source);
}
2 changes: 1 addition & 1 deletion src/asynciterable/for.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncIterableX } from '../asynciterable';
import { concatAll } from './concat';
import { concatAll } from './concatall';
import { map } from './map';

export function _for<TSource, TResult>(
Expand Down
Loading

0 comments on commit 752aa96

Please sign in to comment.