diff --git a/package-lock.json b/package-lock.json index f6bdc65..2b69e18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16058,9 +16058,9 @@ "dev": true }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", + "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 9bf56a6..9d43512 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "tslint-config-prettier": "^1.10.0", "tslint-config-standard": "^7.0.0", "tslint-eslint-rules": "^5.3.1", - "typescript": "^2.8.1" + "typescript": "^3.0.1" }, "config": { "commitizen": { diff --git a/src/core/Observable.ts b/src/core/Observable.ts index 76f32a3..f044c82 100644 --- a/src/core/Observable.ts +++ b/src/core/Observable.ts @@ -1,6 +1,7 @@ // tslint:disable max-classes-per-file no-use-before-declare import $$observable from 'symbol-observable' import { + ArrayValues, Disposer, PartialObserver, SignalType, @@ -190,18 +191,13 @@ class ConcreteObserver implements SubscriptionObserver { } export class Observable implements Subscribable { - static of(): Observable - static of(a: A): Observable - static of(a: A, b: B): Observable - static of(a: A, b: B, c: C): Observable - static of(a: A, b: B, c: C, d: D): Observable - static of(a: A, b: B, c: C, d: D, e: E): Observable + static of(...args: TS): Observable> static of() { const C = typeof this === 'function' ? this : Observable return new C(fromArray(arguments)) } - static from(ish: Observable | Iterable) { + static from(ish: Subscribable | Observable | Iterable) { const C = typeof this === 'function' ? this : Observable const error = `${ish} is not an object` diff --git a/src/core/types.h.ts b/src/core/types.h.ts index 6919771..72c1677 100644 --- a/src/core/types.h.ts +++ b/src/core/types.h.ts @@ -56,3 +56,5 @@ export const enum SignalType { error, complete } + +export type ArrayValues = TS extends Array ? T : void diff --git a/src/helpers/debounce.ts b/src/helpers/debounce.ts index 0191f0c..9ad248a 100644 --- a/src/helpers/debounce.ts +++ b/src/helpers/debounce.ts @@ -1,7 +1,7 @@ -export const debounce = (wait: number, func: (this: This, ...args: any[]) => void) => { +export const debounce = (wait: number, func: (...args: TS) => void) => { let timeoutId: any = null - return function(this: This, ...args: any[]): void { + return function(this: any, ...args: TS): void { timeoutId > 0 && clearTimeout(timeoutId) timeoutId = setTimeout(() => { diff --git a/src/helpers/throttle.ts b/src/helpers/throttle.ts index 7b43ebf..acf2777 100644 --- a/src/helpers/throttle.ts +++ b/src/helpers/throttle.ts @@ -2,10 +2,10 @@ * Creates a throttled function that only invokes func at most once per every `wait` milliseconds. * Function is called on the beginning of `wait` period. */ -export const throttle = (wait: number, func: (this: This, ...args: any[]) => void) => { +export const throttle = (wait: number, func: (...args: TS) => void) => { let timeoutId: any - return function(this: This, ...args: any[]): void { + return function(this: any, ...args: TS): void { if (timeoutId) { return } diff --git a/src/helpers/throttleEnd.ts b/src/helpers/throttleEnd.ts index 0b8eee2..b676e8a 100644 --- a/src/helpers/throttleEnd.ts +++ b/src/helpers/throttleEnd.ts @@ -1,8 +1,8 @@ -export const throttleEnd = (wait: number, fn: (this: This, ...args: any[]) => void) => { - let lastValues: any[] = [] +export const throttleEnd = (wait: number, fn: (...args: TS) => void) => { + let lastValues: TS let timeout: any - return function(this: This, ...args: any[]): void { + return function(this: any, ...args: TS): void { lastValues = args if (timeout) { diff --git a/src/helpers/types/concat.ts b/src/helpers/types/concat.ts new file mode 100644 index 0000000..f01da39 --- /dev/null +++ b/src/helpers/types/concat.ts @@ -0,0 +1,123 @@ +// tslint:disable no-shadowed-variable +// prettier-ignore +export type Concat = AS extends [infer AA] ? + BS extends [infer BA] ? [AA, BA] : + BS extends [infer BA, infer BB] ? [AA, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB] ? + BS extends [infer BA] ? [AA, AB, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC] ? + BS extends [infer BA] ? [AA, AB, AC, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD] ? + BS extends [infer BA] ? [AA, AB, AC, AD, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE, infer AF] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, AF, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, AF, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, AF, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE, infer AF, infer AG] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, AF, AG, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, AF, AG, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE, infer AF, infer AG, infer AH] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, AF, AG, AH, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE, infer AF, infer AG, infer AH, infer AI] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +AS extends [infer AA, infer AB, infer AC, infer AD, infer AE, infer AF, infer AG, infer AH, infer AI, infer AJ] ? + BS extends [infer BA] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA] : + BS extends [infer BA, infer BB] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB] : + BS extends [infer BA, infer BB, infer BC] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC] : + BS extends [infer BA, infer BB, infer BC, infer BD] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE, BF] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE, BF, BG] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE, BF, BG, BH] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE, BF, BG, BH, BI] : + BS extends [infer BA, infer BB, infer BC, infer BD, infer BE, infer BF, infer BG, infer BH, infer BI, infer BK] ? [AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, BA, BB, BC, BD, BE, BF, BG, BH, BI, BK] : + any[] : +any[] diff --git a/src/helpers/types/extractInnnerTypes.ts b/src/helpers/types/extractInnnerTypes.ts new file mode 100644 index 0000000..2a68364 --- /dev/null +++ b/src/helpers/types/extractInnnerTypes.ts @@ -0,0 +1,82 @@ +// tslint:disable no-shadowed-variable +import { Subscribable } from '../../core/types.h' + +export type ExtractInnerTypes>> = TS extends [] + ? [] + : TS extends [Subscribable] + ? [A] + : TS extends [Subscribable, Subscribable] + ? [A, B] + : TS extends [Subscribable, Subscribable, Subscribable] + ? [A, B, C] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E, F] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E, F, G] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E, F, G, H] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E, F, G, H, I] + : TS extends [ + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable, + Subscribable + ] + ? [A, B, C, D, E, F, G, H, I, J] + : any[] diff --git a/src/observable/combineLatest.ts b/src/observable/combineLatest.ts index 4e35df4..329240c 100644 --- a/src/observable/combineLatest.ts +++ b/src/observable/combineLatest.ts @@ -2,23 +2,12 @@ import { Observable } from '../core/Observable' import { Subscribable, Subscription } from '../core/types.h' import { getSpecies } from '../helpers/getSpecies' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' import { EMPTY } from './empty' -// TODO: replace with spread after TS3.0 release -export function combineLatest(): Observable -export function combineLatest(s: Observable): Observable<[A]> -export function combineLatest(sA: Observable, sB: Observable): Observable<[A, B]> -export function combineLatest( - sA: Observable, - sB: Observable, - sC: Observable -): Observable<[A, B, C]> -export function combineLatest( - sA: Observable, - sB: Observable, - sC: Observable, - sD: Observable -): Observable<[A, B, C, D]> +export function combineLatest>>( + ...streams: TS +): Observable> export function combineLatest(): Observable { if (arguments.length < 1) { return EMPTY diff --git a/src/observable/concat.ts b/src/observable/concat.ts index 2d7835f..7d0104c 100644 --- a/src/observable/concat.ts +++ b/src/observable/concat.ts @@ -1,6 +1,7 @@ import { Observable } from '../core/Observable' -import { Subscribable, Subscription, SubscriptionObserver } from '../core/types.h' +import { ArrayValues, Subscribable, Subscription, SubscriptionObserver } from '../core/types.h' import { getSpecies } from '../helpers/getSpecies' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' const subscribe = ( streams: Array>, @@ -27,34 +28,9 @@ const subscribe = ( }) } -export function concat(arg1: Subscribable): Observable -export function concat(arg1: Subscribable, arg2: Subscribable): Observable -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable -): Observable -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable -): Observable -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable -): Observable -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable, - arg6: Subscribable -): Observable +export function concat>>( + ...args: TS +): Observable>> export function concat(): Observable { const streams: Array> = Array.prototype.slice.call(arguments) const C = getSpecies(streams[0]) diff --git a/src/observable/merge.ts b/src/observable/merge.ts index f9a2f1b..4c70cc5 100644 --- a/src/observable/merge.ts +++ b/src/observable/merge.ts @@ -1,35 +1,11 @@ import { Observable } from '../core/Observable' -import { Subscribable } from '../core/types.h' +import { ArrayValues, Subscribable } from '../core/types.h' import { getSpecies } from '../helpers/getSpecies' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' -export function merge(arg1: Subscribable): Observable -export function merge(arg1: Subscribable, arg2: Subscribable): Observable -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable -): Observable -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable -): Observable -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable -): Observable -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable, - arg6: Subscribable -): Observable +export function merge>>( + ...streams: TS +): Observable>> export function merge(): Observable { const streams: Array> = Array.prototype.slice.call(arguments) const C = getSpecies(streams[0]) diff --git a/src/observable/of.ts b/src/observable/of.ts index 59f4d94..57fc79e 100644 --- a/src/observable/of.ts +++ b/src/observable/of.ts @@ -1,18 +1,7 @@ import { Observable } from '../core/Observable' +import { ArrayValues } from '../core/types.h' -export function of(a: A): Observable -export function of(a: A, b: B): Observable -export function of(a: A, b: B, c: C): Observable -export function of(a: A, b: B, c: C, d: D): Observable -export function of(a: A, b: B, c: C, d: D, e: E): Observable -export function of( - a: A, - b: B, - c: C, - d: D, - e: E, - f: F -): Observable +export function of(...args: TS): Observable> export function of(): Observable { return Observable.of.apply(Observable, arguments) } diff --git a/src/observable/startWith.ts b/src/observable/startWith.ts index 3df29d9..3a896a4 100644 --- a/src/observable/startWith.ts +++ b/src/observable/startWith.ts @@ -1,31 +1,12 @@ import { Observable } from '../core/Observable' -import { Subscribable } from '../core/types.h' +import { ArrayValues, Subscribable } from '../core/types.h' import { getSpecies } from '../helpers/getSpecies' import { concat } from './concat' -export function startWith(stream: Subscribable, a: A): Observable -export function startWith(stream: Subscribable, a: A, b: B): Observable -export function startWith( +export function startWith( stream: Subscribable, - a: A, - b: B, - c: C -): Observable -export function startWith( - stream: Subscribable, - a: A, - b: B, - c: C, - d: D -): Observable -export function startWith( - stream: Subscribable, - a: A, - b: B, - c: C, - d: D, - e: E -): Observable + ...args: TS +): Observable | T> export function startWith(): Observable { const input = Array.prototype.slice.call(arguments, 1) const stream = arguments[0] diff --git a/src/operators/combineLatest.ts b/src/operators/combineLatest.ts index caae2a2..8fed819 100644 --- a/src/operators/combineLatest.ts +++ b/src/operators/combineLatest.ts @@ -1,19 +1,15 @@ import { Observable } from '../core/Observable' -import { Subscribable, Unary } from '../core/types.h' +import { Subscribable } from '../core/types.h' +import { Concat } from '../helpers/types/concat' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' import { combineLatest as combineLatestObservable } from '../observable/combineLatest' -export function combineLatest(): Unary, Observable<[A]>> -export function combineLatest(sA: Subscribable): Unary, Observable<[B, A]>> -export function combineLatest( - sA: Subscribable, - sB: Subscribable -): Unary, Observable<[C, A, B]>> -export function combineLatest( - sA: Subscribable, - sB: Subscribable, - sC: Subscribable -): Unary, Observable<[D, A, B, C]>> -export function combineLatest(...streams: Array>) { +export function combineLatest>>( + ...streams: TS +): (stream: Subscribable) => Observable>> +export function combineLatest() { + const streams: Array> = Array.prototype.slice.call(arguments) + return (stream: Subscribable) => { const allStreams = [stream].concat(streams) diff --git a/src/operators/concat.ts b/src/operators/concat.ts index 3960ba0..de29307 100644 --- a/src/operators/concat.ts +++ b/src/operators/concat.ts @@ -1,34 +1,15 @@ import { Observable } from '../core/Observable' -import { Subscribable, Unary } from '../core/types.h' +import { ArrayValues, Subscribable } from '../core/types.h' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' import { concat as concatObservable } from '../observable/concat' -export function concat(): Unary, Subscribable> -export function concat(arg1: Subscribable): Unary, Subscribable> -export function concat( - arg1: Subscribable, - arg2: Subscribable -): Unary, Subscribable> -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable -): Unary, Subscribable> -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable -): Unary, Subscribable> -export function concat( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable -): Unary, Subscribable> -export function concat( - ...streams: Array> -): Unary, Observable> { +export function concat>>( + ...args: TS +): (stream: Subscribable) => Observable> | T> + +export function concat() { + const streams: Array> = Array.prototype.slice.call(arguments) + return (stream: Subscribable) => { const allStreams = [stream].concat(streams) diff --git a/src/operators/merge.ts b/src/operators/merge.ts index 2996b13..9c0ee9a 100644 --- a/src/operators/merge.ts +++ b/src/operators/merge.ts @@ -1,34 +1,14 @@ import { Observable } from '../core/Observable' -import { Subscribable, Unary } from '../core/types.h' +import { ArrayValues, Subscribable } from '../core/types.h' +import { ExtractInnerTypes } from '../helpers/types/extractInnnerTypes' import { merge as mergeObservable } from '../observable/merge' -export function merge(): Unary, Subscribable> -export function merge(arg1: Subscribable): Unary, Subscribable> -export function merge( - arg1: Subscribable, - arg2: Subscribable -): Unary, Subscribable> -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable -): Unary, Subscribable> -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable -): Unary, Subscribable> -export function merge( - arg1: Subscribable, - arg2: Subscribable, - arg3: Subscribable, - arg4: Subscribable, - arg5: Subscribable -): Unary, Subscribable> -export function merge( - ...streams: Array> -): Unary, Observable> { +export function merge>>( + ...streams: TS +): (stream: Subscribable) => Observable>> +export function merge() { + const streams: Array> = Array.prototype.slice.call(arguments) + return (stream: Subscribable) => { const allStreams = [stream].concat(streams) diff --git a/src/operators/startWith.ts b/src/operators/startWith.ts index a4a5ae7..ed6d749 100644 --- a/src/operators/startWith.ts +++ b/src/operators/startWith.ts @@ -1,27 +1,10 @@ import { Observable } from '../core/Observable' -import { Subscribable } from '../core/types.h' +import { ArrayValues, Subscribable } from '../core/types.h' import { startWith as startWithObservable } from '../observable/startWith' -export function startWith(a: A): (stream: Subscribable) => Observable -export function startWith(a: A, b: B): (stream: Subscribable) => Observable -export function startWith( - a: A, - b: B, - c: C -): (stream: Subscribable) => Observable -export function startWith( - a: A, - b: B, - c: C, - d: D -): (stream: Subscribable) => Observable -export function startWith( - a: A, - b: B, - c: C, - d: D, - e: E -): (stream: Subscribable) => Observable +export function startWith( + ...args: TS +): (stream: Subscribable) => Observable | T> export function startWith() { const input = Array.prototype.slice.call(arguments)