From 011ad8aadf682ff29fa1f51da4c3d587e209c0d2 Mon Sep 17 00:00:00 2001 From: Eric Ponto Date: Mon, 20 Feb 2017 23:24:11 -0600 Subject: [PATCH 01/77] fix(AjaxObservable): Use encodeURIComponent to encode request body The contentType 'application/x-www-form-urlencoded' was using `encodeURI` but should be using `encodeURIComponent` on the request body. closes #2389 --- spec/observables/dom/ajax-spec.ts | 19 +++++++++++++++++++ src/observable/dom/AjaxObservable.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/observables/dom/ajax-spec.ts b/spec/observables/dom/ajax-spec.ts index 854380f2bc..d736357802 100644 --- a/spec/observables/dom/ajax-spec.ts +++ b/spec/observables/dom/ajax-spec.ts @@ -418,6 +418,25 @@ describe('Observable.ajax', () => { expect(MockXMLHttpRequest.mostRecent.data).to.equal('%F0%9F%8C%9F=%F0%9F%9A%80'); }); + it('should send by form-urlencoded format with special characters', () => { + const body = { + 'foo=bar': 'foo?bar' + }; + const obj = { + url: '/flibbertyJibbet', + method: '', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: body + }; + + Rx.Observable.ajax(obj).subscribe(); + + expect(MockXMLHttpRequest.mostRecent.url).to.equal('/flibbertyJibbet'); + expect(MockXMLHttpRequest.mostRecent.data).to.equal('foo%3Dbar=foo%3Fbar'); + }); + it('should send by JSON', () => { const body = { '🌟': '🚀' diff --git a/src/observable/dom/AjaxObservable.ts b/src/observable/dom/AjaxObservable.ts index 6ceb35c801..085e7823dd 100644 --- a/src/observable/dom/AjaxObservable.ts +++ b/src/observable/dom/AjaxObservable.ts @@ -282,7 +282,7 @@ export class AjaxSubscriber extends Subscriber { switch (contentType) { case 'application/x-www-form-urlencoded': - return Object.keys(body).map(key => `${encodeURI(key)}=${encodeURI(body[key])}`).join('&'); + return Object.keys(body).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(body[key])}`).join('&'); case 'application/json': return JSON.stringify(body); default: From 0b59a50c8d9c39d9d1e65fb66f604b228d911ea5 Mon Sep 17 00:00:00 2001 From: Mateusz Podlasin Date: Thu, 16 Mar 2017 17:16:56 +0100 Subject: [PATCH 02/77] docs(using): document the operator Document 'using' operator, describing what it accepts and returns. Describe how resulting Observable will behave and when unsubscribe method from resource object will be called. --- src/observable/UsingObservable.ts | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/observable/UsingObservable.ts b/src/observable/UsingObservable.ts index 45a5a39d13..64f0b75a62 100644 --- a/src/observable/UsingObservable.ts +++ b/src/observable/UsingObservable.ts @@ -10,7 +10,37 @@ import { OuterSubscriber } from '../OuterSubscriber'; * @hide true */ export class UsingObservable extends Observable { - + /** + * Creates an Observable that uses a resource which will be disposed at the same time as the Observable. + * + * Use it when you catch yourself cleaning up after an Observable. + * + * `using` is a factory operator, which accepts two functions. First function returns a disposable resource. + * It can be an arbitrary object that implements `unsubscribe` method. Second function will be injected with + * that object and should return an Observable. That Observable can use resource object during its execution. + * Both functions passed to `using` will be called every time someone subscribes - neither an Observable nor + * resource object will be shared in any way between subscriptions. + * + * When Observable returned by `using` is subscribed, Observable returned from the second function will be subscribed + * as well. All its notifications (nexted values, completion and error events) will be emitted unchanged by the output + * Observable. If however someone unsubscribes from the Observable or source Observable completes or errors by itself, + * the `unsubscribe` method on resource object will be called. This can be used to do any necessary clean up, which + * otherwise would have to be handled by hand. Note that complete or error notifications are not emitted when someone + * cancels subscription to an Observable via `unsubscribe`, so `using` can be used as a hook, allowing you to make + * sure that all resources which need to exist during an Observable execution will be disposed at appropriate time. + * + * @see {@link defer} + * + * @param {function(): ISubscription} resourceFactory A function which creates any resource object + * that implements `unsubscribe` method. + * @param {function(resource: ISubscription): Observable} observableFactory A function which + * creates an Observable, that can use injected resource object. + * @return {Observable} An Observable that behaves the same as Observable returned by `observableFactory`, but + * which - when completed, errored or unsubscribed - will also call `unsubscribe` on created resource object. + * @static true + * @name using + * @owner Observable + */ static create(resourceFactory: () => AnonymousSubscription | void, observableFactory: (resource: AnonymousSubscription) => SubscribableOrPromise | void): Observable { return new UsingObservable(resourceFactory, observableFactory); From 524f3ca99a7dc5418c59ba326d4ae3e6a5998e69 Mon Sep 17 00:00:00 2001 From: Mateusz Podlasin Date: Sun, 2 Apr 2017 19:43:46 +0200 Subject: [PATCH 03/77] docs(finally): add documentation for the operator Describe what parameters 'finally' accepts. Emphasize when function passed to the operator is called. Compare the operator with 'subscribe'. Add examples for calling function passed to 'finally' on complete and on unsubscribe. --- src/operator/finally.ts | 66 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/operator/finally.ts b/src/operator/finally.ts index 269858a580..67fdfc35a7 100644 --- a/src/operator/finally.ts +++ b/src/operator/finally.ts @@ -5,10 +5,72 @@ import { Observable } from '../Observable'; /** * Returns an Observable that mirrors the source Observable, but will call a specified function when - * the source terminates on complete or error. - * @param {function} callback Function to be called when source terminates. + * the source terminates on complete, error or unsubscribe. + * + * Ensure a given function will be called when a stream ends, no matter why it ended. + * + * `finally` method accepts as a single parameter a function. This function does not accept any parameters and + * should not return anything. It will be called whenever source Observable completes, errors or is unsubscribed, + * which makes it good candidate to perform any necessary clean up or side effects when Observable terminates, + * no matter how or why it terminated. + * + * Observable returned by `finally` will simply mirror source Observable - each time it is subscribed, source + * Observable will be subscribed underneath. + * + * Note that behavior of `finally` will be repeated per every subscription, so if resulting Observable has + * many subscribers, function passed to `finally` might be potentially called multiple times. + * + * Remember also that `finally` differs quite a lot from passing complete or error handler to {@link subscribe}. It will + * return an Observable which can be further chained, while `subscribe` returns Subscription, basically ending Observable + * chain. Function passed to `finally` will be called also when consumer of resulting Observable unsubscribes from it, + * while handlers passed to `subscribe` will not (even complete handler). But most importantly, `finally` does not start + * an execution of source Observable, like `subscribe` does, allowing you to set up all necessary hooks before + * passing Observable further, even without specific knowledge how or when it will be used. + * + * + * @example Call finally after complete notification + * Rx.Observable.of(1, 2, 3) + * .finally(() => console.log('I was finalized!')) + * .map(x => x * 2) // `finally` returns an Observable, so we still can chain operators. + * .subscribe( + * val => console.log(val), + * err => {}, + * () => console.log('I completed!') + * ); + * + * // Logs: + * // 1 + * // 2 + * // 3 + * // "I completed!" + * // "I was finalized!" + * + * + * + * @example Call finally after consumer unsubscribes + * const o = Rx.Observable.interval(1000) + * .finally(() => console.log('Timer stopped')); + * + * const subscription = o.subscribe( + * val => console.log(val), + * err => {}, + * () => console.log('Complete!') // Will not be called, since complete handler + * ); // does not react to unsubscription, just to + * // complete notification sent by the Observable itself. + * + * setTimeout(() => subscription.unsubscribe(), 2500); + * + * // Logs: + * // 0 after 1s + * // 1 after 2s + * // "Timer stopped" after 2.5s + * + * @see {@link using} + * + * @param {function} callback Function to be called when source terminates (completes, errors or is unsubscribed). * @return {Observable} An Observable that mirrors the source, but will call the specified function on termination. * @method finally + * @name finally * @owner Observable */ export function _finally(this: Observable, callback: () => void): Observable { From a959806cf933db207f7d8989875539f6125b6d70 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 22 Sep 2017 22:38:18 -0700 Subject: [PATCH 04/77] refactor(spec): import module from source directly --- spec/Notification-spec.ts | 5 +- spec/Observable-spec.ts | 12 +++-- spec/Scheduler-spec.ts | 2 +- spec/Subject-spec.ts | 2 +- spec/Subscriber-spec.ts | 2 +- spec/Subscription-spec.ts | 2 +- spec/exports-spec.ts | 52 +++++++++---------- spec/helpers/ambient.d.ts | 12 ----- spec/helpers/marble-testing.ts | 10 ++-- spec/helpers/test-helper.ts | 39 +++++++------- spec/helpers/testScheduler-ui.ts | 52 ++++++++++--------- spec/observables/IteratorObservable-spec.ts | 6 +-- spec/observables/ScalarObservable-spec.ts | 4 +- .../observables/SubscribeOnObservable-spec.ts | 4 +- spec/observables/bindCallback-spec.ts | 2 +- spec/observables/bindNodeCallback-spec.ts | 2 +- spec/observables/combineLatest-spec.ts | 2 +- spec/observables/concat-spec.ts | 2 +- spec/observables/defer-spec.ts | 2 +- spec/observables/dom/ajax-spec.ts | 4 +- spec/observables/dom/webSocket-spec.ts | 2 +- spec/observables/empty-spec.ts | 2 +- spec/observables/forkJoin-spec.ts | 2 +- spec/observables/from-promise-spec.ts | 2 +- spec/observables/from-spec.ts | 2 +- spec/observables/fromEvent-spec.ts | 2 +- spec/observables/fromEventPattern-spec.ts | 4 +- spec/observables/generate-spec.ts | 6 +-- spec/observables/if-spec.ts | 2 +- spec/observables/interval-spec.ts | 2 +- spec/observables/merge-spec.ts | 2 +- spec/observables/never-spec.ts | 2 +- spec/observables/of-spec.ts | 8 +-- spec/observables/onErrorResumeNext-spec.ts | 2 +- spec/observables/pairs-spec.ts | 2 +- spec/observables/race-spec.ts | 2 +- spec/observables/range-spec.ts | 4 +- spec/observables/throw-spec.ts | 4 +- spec/observables/timer-spec.ts | 2 +- spec/observables/using-spec.ts | 2 +- spec/observables/zip-spec.ts | 2 +- spec/operators/audit-spec.ts | 2 +- spec/operators/auditTime-spec.ts | 2 +- spec/operators/buffer-spec.ts | 2 +- spec/operators/bufferCount-spec.ts | 2 +- spec/operators/bufferTime-spec.ts | 2 +- spec/operators/bufferToggle-spec.ts | 2 +- spec/operators/bufferWhen-spec.ts | 2 +- spec/operators/catch-spec.ts | 2 +- spec/operators/combineAll-spec.ts | 2 +- spec/operators/combineLatest-spec.ts | 2 +- spec/operators/concat-spec.ts | 2 +- spec/operators/concatAll-spec.ts | 2 +- spec/operators/concatMap-spec.ts | 2 +- spec/operators/concatMapTo-spec.ts | 2 +- spec/operators/count-spec.ts | 2 +- spec/operators/debounce-spec.ts | 2 +- spec/operators/debounceTime-spec.ts | 2 +- spec/operators/defaultIfEmpty-spec.ts | 2 +- spec/operators/delay-spec.ts | 2 +- spec/operators/delayWhen-spec.ts | 2 +- spec/operators/dematerialize-spec.ts | 2 +- spec/operators/distinct-spec.ts | 2 +- spec/operators/distinctUntilChanged-spec.ts | 2 +- .../operators/distinctUntilKeyChanged-spec.ts | 2 +- spec/operators/do-spec.ts | 2 +- spec/operators/elementAt-spec.ts | 2 +- spec/operators/every-spec.ts | 2 +- spec/operators/exhaust-spec.ts | 2 +- spec/operators/exhaustMap-spec.ts | 2 +- spec/operators/expand-spec.ts | 2 +- spec/operators/filter-spec.ts | 2 +- spec/operators/finally-spec.ts | 2 +- spec/operators/find-spec.ts | 2 +- spec/operators/findIndex-spec.ts | 2 +- spec/operators/first-spec.ts | 2 +- spec/operators/groupBy-spec.ts | 4 +- spec/operators/ignoreElements-spec.ts | 2 +- spec/operators/isEmpty-spec.ts | 2 +- spec/operators/last-spec.ts | 2 +- spec/operators/let-spec.ts | 2 +- spec/operators/map-spec.ts | 2 +- spec/operators/mapTo-spec.ts | 2 +- spec/operators/materialize-spec.ts | 2 +- spec/operators/max-spec.ts | 2 +- spec/operators/merge-spec.ts | 2 +- spec/operators/mergeAll-spec.ts | 2 +- spec/operators/mergeMap-spec.ts | 2 +- spec/operators/mergeMapTo-spec.ts | 2 +- spec/operators/mergeScan-spec.ts | 2 +- spec/operators/min-spec.ts | 2 +- spec/operators/multicast-spec.ts | 2 +- spec/operators/observeOn-spec.ts | 2 +- spec/operators/onErrorResumeNext-spec.ts | 2 +- spec/operators/partition-spec.ts | 2 +- spec/operators/pluck-spec.ts | 2 +- spec/operators/publish-spec.ts | 2 +- spec/operators/publishBehavior-spec.ts | 2 +- spec/operators/publishLast-spec.ts | 2 +- spec/operators/publishReplay-spec.ts | 2 +- spec/operators/race-spec.ts | 2 +- spec/operators/reduce-spec.ts | 2 +- spec/operators/refCount-spec.ts | 2 +- spec/operators/repeat-spec.ts | 2 +- spec/operators/repeatWhen-spec.ts | 2 +- spec/operators/retry-spec.ts | 2 +- spec/operators/retryWhen-spec.ts | 2 +- spec/operators/sample-spec.ts | 2 +- spec/operators/sampleTime-spec.ts | 2 +- spec/operators/scan-spec.ts | 2 +- spec/operators/share-spec.ts | 2 +- spec/operators/shareReplay-spec.ts | 2 +- spec/operators/single-spec.ts | 2 +- spec/operators/skip-spec.ts | 2 +- spec/operators/skipLast-spec.ts | 2 +- spec/operators/skipUntil-spec.ts | 2 +- spec/operators/skipWhile-spec.ts | 2 +- spec/operators/startWith-spec.ts | 2 +- spec/operators/subscribeOn-spec.ts | 2 +- spec/operators/switch-spec.ts | 2 +- spec/operators/switchMap-spec.ts | 2 +- spec/operators/switchMapTo-spec.ts | 2 +- spec/operators/take-spec.ts | 2 +- spec/operators/takeLast-spec.ts | 2 +- spec/operators/takeUntil-spec.ts | 2 +- spec/operators/takeWhile-spec.ts | 2 +- spec/operators/throttle-spec.ts | 2 +- spec/operators/throttleTime-spec.ts | 2 +- spec/operators/timeInterval-spec.ts | 2 +- spec/operators/timeout-spec.ts | 2 +- spec/operators/timeoutWith-spec.ts | 2 +- spec/operators/timestamp-spec.ts | 2 +- spec/operators/toArray-spec.ts | 2 +- spec/operators/toPromise-spec.ts | 2 +- spec/operators/window-spec.ts | 2 +- spec/operators/windowCount-spec.ts | 2 +- spec/operators/windowTime-spec.ts | 2 +- spec/operators/windowToggle-spec.ts | 2 +- spec/operators/windowWhen-spec.ts | 2 +- spec/operators/withLatestFrom-spec.ts | 2 +- spec/operators/zip-spec.ts | 2 +- spec/operators/zipAll-spec.ts | 2 +- spec/root-module-spec.ts | 2 +- .../AnimationFrameScheduler-spec.ts | 2 +- spec/schedulers/AsapScheduler-spec.ts | 2 +- spec/schedulers/QueueScheduler-spec.ts | 2 +- spec/schedulers/TestScheduler-spec.ts | 2 +- spec/schedulers/VirtualTimeScheduler-spec.ts | 4 +- spec/subjects/AsyncSubject-spec.ts | 2 +- spec/subjects/BehaviorSubject-spec.ts | 2 +- spec/subjects/ReplaySubject-spec.ts | 4 +- spec/support/debug.opts | 12 ----- spec/support/default.opts | 4 +- spec/symbol/iterator-spec.ts | 2 +- spec/symbol/observable-polyfilled-spec.ts | 2 +- spec/symbol/observable-spec.ts | 4 +- spec/symbol/rxSubscriber-spec.ts | 4 +- spec/util/FastMap-spec.ts | 2 +- spec/util/Immediate-spec.ts | 4 +- spec/util/MapPolyfill-spec.ts | 2 +- spec/util/Set-spec.ts | 2 +- spec/util/UnsubscriptionError-spec.ts | 2 +- spec/util/assign-spec.ts | 6 +-- spec/util/pipe-spec.ts | 2 +- spec/util/root-spec.ts | 2 +- spec/util/subscribeToResult-spec.ts | 12 ++--- spec/util/toSubscriber-spec.ts | 2 +- 167 files changed, 276 insertions(+), 290 deletions(-) delete mode 100644 spec/helpers/ambient.d.ts delete mode 100644 spec/support/debug.opts diff --git a/spec/Notification-spec.ts b/spec/Notification-spec.ts index b92b504d59..faeb92d2ff 100644 --- a/spec/Notification-spec.ts +++ b/spec/Notification-spec.ts @@ -1,7 +1,8 @@ import { expect } from 'chai'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; +import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports -declare const expectObservable; +declare const expectObservable: typeof marbleTestingSignature.expectObservable; const Notification = Rx.Notification; /** @test {Notification} */ diff --git a/spec/Observable-spec.ts b/spec/Observable-spec.ts index 16bdad8f6d..9d3d7590fb 100644 --- a/spec/Observable-spec.ts +++ b/spec/Observable-spec.ts @@ -1,11 +1,13 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../dist/package/Rx'; -import { TeardownLogic } from '../dist/package/Subscription'; +import * as Rx from '../src/Rx'; +import { TeardownLogic } from '../src/Subscription'; import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports -import { map } from '../dist/package/operators/map'; +import { map } from '../src/operators/map'; +//tslint:disable-next-line +require('./helpers/test-helper'); -declare const { asDiagram, rxTestScheduler }; +declare const asDiagram: any, rxTestScheduler: any; declare const cold: typeof marbleTestingSignature.cold; declare const expectObservable: typeof marbleTestingSignature.expectObservable; declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions; @@ -15,7 +17,7 @@ const Observable = Rx.Observable; declare const __root__: any; -function expectFullObserver(val) { +function expectFullObserver(val: any) { expect(val).to.be.a('object'); expect(val.next).to.be.a('function'); expect(val.error).to.be.a('function'); diff --git a/spec/Scheduler-spec.ts b/spec/Scheduler-spec.ts index d3eec8cc05..4dff8e3ac7 100644 --- a/spec/Scheduler-spec.ts +++ b/spec/Scheduler-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; const Scheduler = Rx.Scheduler; diff --git a/spec/Subject-spec.ts b/spec/Subject-spec.ts index 938c5f768f..8bc1e19d19 100644 --- a/spec/Subject-spec.ts +++ b/spec/Subject-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { time }; diff --git a/spec/Subscriber-spec.ts b/spec/Subscriber-spec.ts index 68fa76547c..cd2d13e18c 100644 --- a/spec/Subscriber-spec.ts +++ b/spec/Subscriber-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; const Subscriber = Rx.Subscriber; diff --git a/spec/Subscription-spec.ts b/spec/Subscription-spec.ts index 2bc6a69b10..4fc0cd015f 100644 --- a/spec/Subscription-spec.ts +++ b/spec/Subscription-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; const Observable = Rx.Observable; const Subscription = Rx.Subscription; diff --git a/spec/exports-spec.ts b/spec/exports-spec.ts index d8276328cf..1e481295c6 100644 --- a/spec/exports-spec.ts +++ b/spec/exports-spec.ts @@ -1,29 +1,29 @@ import { expect } from 'chai'; -import { bindCallback } from '../dist/package/observable/bindCallback'; -import { bindNodeCallback } from '../dist/package/observable/bindNodeCallback'; -import { combineLatest } from '../dist/package/observable/combineLatest'; -import { concat } from '../dist/package/observable/concat'; -import { defer } from '../dist/package/observable/defer'; -import { empty } from '../dist/package/observable/empty'; -import { forkJoin } from '../dist/package/observable/forkJoin'; -import { from } from '../dist/package/observable/from'; -import { fromEvent } from '../dist/package/observable/fromEvent'; -import { fromEventPattern } from '../dist/package/observable/fromEventPattern'; -import { fromPromise } from '../dist/package/observable/fromPromise'; -import { _if } from '../dist/package/observable/if'; -import { interval } from '../dist/package/observable/interval'; -import { merge } from '../dist/package/observable/merge'; -import { never } from '../dist/package/observable/never'; -import { of } from '../dist/package/observable/of'; -import { onErrorResumeNext } from '../dist/package/observable/onErrorResumeNext'; -import { pairs } from '../dist/package/observable/pairs'; -import { race } from '../dist/package/observable/race'; -import { range } from '../dist/package/observable/range'; -import { _throw } from '../dist/package/observable/throw'; -import { timer } from '../dist/package/observable/timer'; -import { using } from '../dist/package/observable/using'; -import { zip } from '../dist/package/observable/zip'; -import * as Rx from '../dist/package/Rx'; +import { bindCallback } from '../src/observable/bindCallback'; +import { bindNodeCallback } from '../src/observable/bindNodeCallback'; +import { combineLatest } from '../src/observable/combineLatest'; +import { concat } from '../src/observable/concat'; +import { defer } from '../src/observable/defer'; +import { empty } from '../src/observable/empty'; +import { forkJoin } from '../src/observable/forkJoin'; +import { from } from '../src/observable/from'; +import { fromEvent } from '../src/observable/fromEvent'; +import { fromEventPattern } from '../src/observable/fromEventPattern'; +import { fromPromise } from '../src/observable/fromPromise'; +import { _if } from '../src/observable/if'; +import { interval } from '../src/observable/interval'; +import { merge } from '../src/observable/merge'; +import { never } from '../src/observable/never'; +import { of } from '../src/observable/of'; +import { onErrorResumeNext } from '../src/observable/onErrorResumeNext'; +import { pairs } from '../src/observable/pairs'; +import { race } from '../src/observable/race'; +import { range } from '../src/observable/range'; +import { _throw } from '../src/observable/throw'; +import { timer } from '../src/observable/timer'; +import { using } from '../src/observable/using'; +import { zip } from '../src/observable/zip'; +import * as Rx from '../src/Rx'; describe('exports', () => { it('should have rxjs/observable/bindCallback', () => { @@ -121,4 +121,4 @@ describe('exports', () => { it('should have rxjs/observable/zip', () => { expect(zip).to.equal(Rx.Observable.zip); }); -}); +}); \ No newline at end of file diff --git a/spec/helpers/ambient.d.ts b/spec/helpers/ambient.d.ts deleted file mode 100644 index 3956841d80..0000000000 --- a/spec/helpers/ambient.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -//ambient declarations to allow modules do not have type definition -declare module 'mocha/lib/interfaces/common' { -} - -declare module 'escape-string-regexp' { -} - -declare module 'mocha/lib/suite' { -} - -declare module 'mocha/lib/test' { -} \ No newline at end of file diff --git a/spec/helpers/marble-testing.ts b/spec/helpers/marble-testing.ts index e00b046780..1589bb2941 100644 --- a/spec/helpers/marble-testing.ts +++ b/spec/helpers/marble-testing.ts @@ -1,9 +1,9 @@ /// -import { Observable } from '../../dist/package/Observable'; -import { SubscriptionLog } from '../../dist/package/testing/SubscriptionLog'; -import { ColdObservable } from '../../dist/package/testing/ColdObservable'; -import { HotObservable } from '../../dist/package/testing/HotObservable'; -import { TestScheduler, observableToBeFn, subscriptionLogsToBeFn } from '../../dist/package/testing/TestScheduler'; +import { Observable } from '../../src/Observable'; +import { SubscriptionLog } from '../../src/testing/SubscriptionLog'; +import { ColdObservable } from '../../src/testing/ColdObservable'; +import { HotObservable } from '../../src/testing/HotObservable'; +import { TestScheduler, observableToBeFn, subscriptionLogsToBeFn } from '../../src/testing/TestScheduler'; declare const global: any; diff --git a/spec/helpers/test-helper.ts b/spec/helpers/test-helper.ts index 1e46ef0da1..24a8626348 100644 --- a/spec/helpers/test-helper.ts +++ b/spec/helpers/test-helper.ts @@ -1,16 +1,17 @@ /// declare const global: any; -import * as Rx from '../../dist/package/Rx'; -import { ObservableInput } from '../../dist/package/Observable'; -import { root } from '../../dist/package/util/root'; -import {$$iterator} from '../../dist/package/symbol/iterator'; +import * as Rx from '../../src/Rx'; +import { ObservableInput } from '../../src/Observable'; +import { root } from '../../src/util/root'; +import { $$iterator } from '../../src/symbol/iterator'; import $$symbolObservable from 'symbol-observable'; +import { Observable } from '../../src/Observable'; -export function lowerCaseO(...args): Rx.Observable { +export function lowerCaseO(...args: Array): Rx.Observable { const o = { - subscribe: function (observer) { + subscribe: function (observer: any) { args.forEach(function (v) { observer.next(v); }); @@ -18,7 +19,7 @@ export function lowerCaseO(...args): Rx.Observable { } }; - o[$$symbolObservable] = function () { + o[$$symbolObservable] = function (this: any) { return this; }; @@ -30,17 +31,19 @@ export const createObservableInputs = (value: T) => Rx.Observable.of(value, Rx.Scheduler.async), [value], Promise.resolve(value), - ({ [$$iterator]: () => { - const iteratorResults = [ - {value, done: false}, - {done: true} - ]; - return { - next: () => { - return iteratorResults.shift(); - } - }; - }}), + ({ + [$$iterator]: () => { + const iteratorResults = [ + { value, done: false }, + { done: true } + ]; + return { + next: () => { + return iteratorResults.shift(); + } + }; + } + }), ({ [$$symbolObservable]: () => Rx.Observable.of(value) }) ); diff --git a/spec/helpers/testScheduler-ui.ts b/spec/helpers/testScheduler-ui.ts index 7b425222d7..5d0c2d455c 100644 --- a/spec/helpers/testScheduler-ui.ts +++ b/spec/helpers/testScheduler-ui.ts @@ -1,19 +1,23 @@ /// -/// import * as _ from 'lodash'; -import * as commonInterface from 'mocha/lib/interfaces/common'; -import * as escapeRe from 'escape-string-regexp'; +//import * as commonInterface from 'mocha/lib/interfaces/common'; +//import * as escapeRe from 'escape-string-regexp'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import * as marble from './marble-testing'; +//tslint:disable:no-var-requires no-require-imports +const commonInterface = require('mocha/lib/interfaces/common'); +const escapeRe = require('escape-string-regexp'); +//tslint:enable:no-var-requires no-require-imports + //setup sinon-chai chai.use(sinonChai); -declare const module, global, Suite, Test: any; +declare const module: any, global: any, Suite: any, Test: any; if (global && !(typeof window !== 'undefined')) { global.mocha = require('mocha'); // tslint:disable-line:no-require-imports no-var-requires @@ -29,10 +33,10 @@ const diagramFunction = global.asDiagram; //mocha creates own global context per each test suite, simple patching to global won't deliver its context into test cases. //this custom interface is just mimic of existing one amending test scheduler behavior previously test-helper does via global patching. -module.exports = function(suite) { +module.exports = function(suite: any) { const suites = [suite]; - suite.on('pre-require', function(context, file, mocha) { + suite.on('pre-require', function(context: any, file: any, mocha: any) { const common = (commonInterface)(suites, context); context.before = common.before; @@ -57,7 +61,7 @@ module.exports = function(suite) { * and/or tests. */ - context.describe = context.context = function(title, fn) { + context.describe = context.context = function(title: any, fn: any) { const suite = (Suite).create(suites[0], title); suite.file = file; suites.unshift(suite); @@ -70,7 +74,7 @@ module.exports = function(suite) { * Pending describe. */ - context.xdescribe = context.xcontext = context.describe.skip = function(title, fn) { + context.xdescribe = context.xcontext = context.describe.skip = function(title: any, fn: any) { const suite = (Suite).create(suites[0], title); suite.pending = true; suites.unshift(suite); @@ -82,7 +86,7 @@ module.exports = function(suite) { * Exclusive suite. */ - context.describe.only = function(title, fn) { + context.describe.only = function(title: any, fn: any) { const suite = context.describe(title, fn); mocha.grep(suite.fullTitle()); return suite; @@ -94,13 +98,13 @@ module.exports = function(suite) { * exceptional type definition won't be used in test cases. */ - context.type = function (title, fn) { + context.type = function(title: any, fn: any) { //intentionally does not execute to avoid unexpected side effect occurs by subscription, //or infinite source. Suffecient to check build time only. }; - function stringify(x): string { - return JSON.stringify(x, function (key, value) { + function stringify(x: any): string { + return JSON.stringify(x, function (key: string, value: any) { if (Array.isArray(value)) { return '[' + value .map(function (i) { @@ -114,7 +118,7 @@ module.exports = function(suite) { .replace(/\\n/g, '\n'); } - function deleteErrorNotificationStack(marble) { + function deleteErrorNotificationStack(marble: any) { const { notification } = marble; if (notification) { const { kind, error } = notification; @@ -129,7 +133,7 @@ module.exports = function(suite) { * custom assertion formatter for expectObservable test */ - function observableMatcher(actual, expected) { + function observableMatcher(actual: any, expected: any) { if (Array.isArray(actual) && Array.isArray(expected)) { actual = actual.map(deleteErrorNotificationStack); expected = expected.map(deleteErrorNotificationStack); @@ -139,10 +143,10 @@ module.exports = function(suite) { } let message = '\nExpected \n'; - actual.forEach((x) => message += `\t${stringify(x)}\n`); + actual.forEach((x: any) => message += `\t${stringify(x)}\n`); message += '\t\nto deep equal \n'; - expected.forEach((x) => message += `\t${stringify(x)}\n`); + expected.forEach((x: any) => message += `\t${stringify(x)}\n`); chai.assert(passed, message); } else { @@ -156,7 +160,7 @@ module.exports = function(suite) { * acting as a thunk. */ - const it = context.it = context.specify = function(title, fn) { + const it = context.it = context.specify = function(title: any, fn: any) { context.rxTestScheduler = null; let modified = fn; @@ -188,7 +192,7 @@ module.exports = function(suite) { * to be represented as marble diagram png. * It will still serve as normal test cases as well. */ - context.asDiagram = function (label) { + context.asDiagram = function (label: any) { if (diagramFunction) { return diagramFunction(label, it); } @@ -199,7 +203,7 @@ module.exports = function(suite) { * Exclusive test-case. */ - context.it.only = function(title, fn) { + context.it.only = function(title: any, fn: any) { const test = it(title, fn); const reString = '^' + (escapeRe)(test.fullTitle()) + '$'; mocha.grep(new RegExp(reString)); @@ -210,14 +214,14 @@ module.exports = function(suite) { * Pending test case. */ - context.xit = context.xspecify = context.it.skip = function(title) { + context.xit = context.xspecify = context.it.skip = function(title: string) { context.it(title); }; /** * Number of attempts to retry. */ - context.it.retries = function(n) { + context.it.retries = function(n: number) { context.retries(n); }; }); @@ -232,10 +236,10 @@ if (global.Mocha) { //overrides JSON.toStringfy to serialize error object Object.defineProperty(Error.prototype, 'toJSON', { - value: function () { + value: function (this: any) { const alt = {}; - Object.getOwnPropertyNames(this).forEach(function (key) { + Object.getOwnPropertyNames(this).forEach(function (this: any, key: string) { if (key !== 'stack') { alt[key] = this[key]; } diff --git a/spec/observables/IteratorObservable-spec.ts b/spec/observables/IteratorObservable-spec.ts index c1fb5afe05..7907a27b80 100644 --- a/spec/observables/IteratorObservable-spec.ts +++ b/spec/observables/IteratorObservable-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { queue } from '../../dist/package/scheduler/queue'; -import { IteratorObservable } from '../../dist/package/observable/IteratorObservable'; +import * as Rx from '../../src/Rx'; +import { queue } from '../../src/scheduler/queue'; +import { IteratorObservable } from '../../src/observable/IteratorObservable'; declare const expectObservable; declare const rxTestScheduler: Rx.TestScheduler; diff --git a/spec/observables/ScalarObservable-spec.ts b/spec/observables/ScalarObservable-spec.ts index 4ac406b5bf..325ab39e23 100644 --- a/spec/observables/ScalarObservable-spec.ts +++ b/spec/observables/ScalarObservable-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { ScalarObservable } from '../../dist/package/observable/ScalarObservable'; +import * as Rx from '../../src/Rx'; +import { ScalarObservable } from '../../src/observable/ScalarObservable'; declare const rxTestScheduler: Rx.TestScheduler; diff --git a/spec/observables/SubscribeOnObservable-spec.ts b/spec/observables/SubscribeOnObservable-spec.ts index 4851c9b470..3e9d88176a 100644 --- a/spec/observables/SubscribeOnObservable-spec.ts +++ b/spec/observables/SubscribeOnObservable-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; -import { SubscribeOnObservable } from '../../dist/package/observable/SubscribeOnObservable'; +import * as Rx from '../../src/Rx'; +import { SubscribeOnObservable } from '../../src/observable/SubscribeOnObservable'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/observables/bindCallback-spec.ts b/spec/observables/bindCallback-spec.ts index 8591520fd4..02f3bbd28e 100644 --- a/spec/observables/bindCallback-spec.ts +++ b/spec/observables/bindCallback-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; diff --git a/spec/observables/bindNodeCallback-spec.ts b/spec/observables/bindNodeCallback-spec.ts index 7992d888b2..16fa09e64d 100644 --- a/spec/observables/bindNodeCallback-spec.ts +++ b/spec/observables/bindNodeCallback-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; declare const rxTestScheduler: Rx.TestScheduler; const Observable = Rx.Observable; diff --git a/spec/observables/combineLatest-spec.ts b/spec/observables/combineLatest-spec.ts index 8a2bb2c3dc..c7a2b0df71 100644 --- a/spec/observables/combineLatest-spec.ts +++ b/spec/observables/combineLatest-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { type }; diff --git a/spec/observables/concat-spec.ts b/spec/observables/concat-spec.ts index aff156edf1..0da4bb15b7 100644 --- a/spec/observables/concat-spec.ts +++ b/spec/observables/concat-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { lowerCaseO } from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/observables/defer-spec.ts b/spec/observables/defer-spec.ts index 092178c95e..1713771162 100644 --- a/spec/observables/defer-spec.ts +++ b/spec/observables/defer-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/dom/ajax-spec.ts b/spec/observables/dom/ajax-spec.ts index 44eebfbc23..19c3e271d7 100644 --- a/spec/observables/dom/ajax-spec.ts +++ b/spec/observables/dom/ajax-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../../dist/package/Rx'; -import { root } from '../../../dist/package/util/root'; +import * as Rx from '../../../src/Rx'; +import { root } from '../../../src/util/root'; declare const global: any; diff --git a/spec/observables/dom/webSocket-spec.ts b/spec/observables/dom/webSocket-spec.ts index e9c109f1b6..b817267aa8 100644 --- a/spec/observables/dom/webSocket-spec.ts +++ b/spec/observables/dom/webSocket-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../../dist/package/Rx'; +import * as Rx from '../../../src/Rx'; declare const __root__: any; diff --git a/spec/observables/empty-spec.ts b/spec/observables/empty-spec.ts index df11f0f386..311b5a675f 100644 --- a/spec/observables/empty-spec.ts +++ b/spec/observables/empty-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/forkJoin-spec.ts b/spec/observables/forkJoin-spec.ts index 6cff0e3ea6..685b5c5aab 100644 --- a/spec/observables/forkJoin-spec.ts +++ b/spec/observables/forkJoin-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { lowerCaseO } from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/observables/from-promise-spec.ts b/spec/observables/from-promise-spec.ts index 2e78747272..1bb3f1369b 100644 --- a/spec/observables/from-promise-spec.ts +++ b/spec/observables/from-promise-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; declare const process: any; const Observable = Rx.Observable; diff --git a/spec/observables/from-spec.ts b/spec/observables/from-spec.ts index b665c28a82..d527ee3ba6 100644 --- a/spec/observables/from-spec.ts +++ b/spec/observables/from-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; declare const {asDiagram, expectObservable, Symbol, type}; declare const rxTestScheduler: Rx.TestScheduler; diff --git a/spec/observables/fromEvent-spec.ts b/spec/observables/fromEvent-spec.ts index 59655eeffd..d6c0cfe0cb 100644 --- a/spec/observables/fromEvent-spec.ts +++ b/spec/observables/fromEvent-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/fromEventPattern-spec.ts b/spec/observables/fromEventPattern-spec.ts index 015c79c16b..2f71e0beea 100644 --- a/spec/observables/fromEventPattern-spec.ts +++ b/spec/observables/fromEventPattern-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; -import { noop } from '../../dist/package/util/noop'; +import * as Rx from '../../src/Rx'; +import { noop } from '../../src/util/noop'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/generate-spec.ts b/spec/observables/generate-spec.ts index 0436bd4d0c..f7c6fa1a0c 100644 --- a/spec/observables/generate-spec.ts +++ b/spec/observables/generate-spec.ts @@ -1,6 +1,6 @@ -import * as Rx from '../../dist/package/Rx'; -import '../../dist/package/add/observable/generate'; -import { TestScheduler } from '../../dist/package/testing/TestScheduler'; +import * as Rx from '../../src/Rx'; +import '../../src/add/observable/generate'; +import { TestScheduler } from '../../src/testing/TestScheduler'; import { expect } from 'chai'; declare const {asDiagram, expectObservable}; declare const rxTestScheduler: TestScheduler; diff --git a/spec/observables/if-spec.ts b/spec/observables/if-spec.ts index 0dc7906df5..22ca35e49a 100644 --- a/spec/observables/if-spec.ts +++ b/spec/observables/if-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const expectObservable: typeof marbleTestingSignature.expectObservable; diff --git a/spec/observables/interval-spec.ts b/spec/observables/interval-spec.ts index dd7538086f..2faded0ddb 100644 --- a/spec/observables/interval-spec.ts +++ b/spec/observables/interval-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/merge-spec.ts b/spec/observables/merge-spec.ts index 2fb95c4973..2147d2849e 100644 --- a/spec/observables/merge-spec.ts +++ b/spec/observables/merge-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { lowerCaseO } from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/observables/never-spec.ts b/spec/observables/never-spec.ts index 093181d97c..124de22f9e 100644 --- a/spec/observables/never-spec.ts +++ b/spec/observables/never-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/of-spec.ts b/spec/observables/of-spec.ts index 6a35fe3150..e5b49d0cd5 100644 --- a/spec/observables/of-spec.ts +++ b/spec/observables/of-spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { ArrayObservable } from '../../dist/package/observable/ArrayObservable'; -import { ScalarObservable } from '../../dist/package/observable/ScalarObservable'; -import { EmptyObservable } from '../../dist/package/observable/EmptyObservable'; +import * as Rx from '../../src/Rx'; +import { ArrayObservable } from '../../src/observable/ArrayObservable'; +import { ScalarObservable } from '../../src/observable/ScalarObservable'; +import { EmptyObservable } from '../../src/observable/EmptyObservable'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/onErrorResumeNext-spec.ts b/spec/observables/onErrorResumeNext-spec.ts index b7ee3a8757..7854dcafa3 100644 --- a/spec/observables/onErrorResumeNext-spec.ts +++ b/spec/observables/onErrorResumeNext-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/observables/pairs-spec.ts b/spec/observables/pairs-spec.ts index 61b7937716..ef8aa05f51 100644 --- a/spec/observables/pairs-spec.ts +++ b/spec/observables/pairs-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/race-spec.ts b/spec/observables/race-spec.ts index 30865b5ada..b2eaa1f7c2 100644 --- a/spec/observables/race-spec.ts +++ b/spec/observables/race-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/observables/range-spec.ts b/spec/observables/range-spec.ts index c6cbf30983..e9d13e929c 100644 --- a/spec/observables/range-spec.ts +++ b/spec/observables/range-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; -import { RangeObservable } from '../../dist/package/observable/RangeObservable'; +import * as Rx from '../../src/Rx'; +import { RangeObservable } from '../../src/observable/RangeObservable'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/throw-spec.ts b/spec/observables/throw-spec.ts index 94adadff2b..577bef871e 100644 --- a/spec/observables/throw-spec.ts +++ b/spec/observables/throw-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { ErrorObservable } from '../../dist/package/observable/ErrorObservable'; +import * as Rx from '../../src/Rx'; +import { ErrorObservable } from '../../src/observable/ErrorObservable'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/observables/timer-spec.ts b/spec/observables/timer-spec.ts index 3e813c6bfd..e09b809ad5 100644 --- a/spec/observables/timer-spec.ts +++ b/spec/observables/timer-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/observables/using-spec.ts b/spec/observables/using-spec.ts index 2bdd822a17..8b5a7a80b0 100644 --- a/spec/observables/using-spec.ts +++ b/spec/observables/using-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const Observable = Rx.Observable; const Subscription = Rx.Subscription; diff --git a/spec/observables/zip-spec.ts b/spec/observables/zip-spec.ts index 8753abe4a9..3be791b039 100644 --- a/spec/observables/zip-spec.ts +++ b/spec/observables/zip-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { type }; diff --git a/spec/operators/audit-spec.ts b/spec/operators/audit-spec.ts index 8e1dca4baf..ebecd4cf86 100644 --- a/spec/operators/audit-spec.ts +++ b/spec/operators/audit-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/auditTime-spec.ts b/spec/operators/auditTime-spec.ts index 81997c7a55..e9d53c0530 100644 --- a/spec/operators/auditTime-spec.ts +++ b/spec/operators/auditTime-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/buffer-spec.ts b/spec/operators/buffer-spec.ts index 6b1bc22a48..c70a13fb11 100644 --- a/spec/operators/buffer-spec.ts +++ b/spec/operators/buffer-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/bufferCount-spec.ts b/spec/operators/bufferCount-spec.ts index 579fc0f9be..d1a0bb4f92 100644 --- a/spec/operators/bufferCount-spec.ts +++ b/spec/operators/bufferCount-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { expect } from 'chai'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/operators/bufferTime-spec.ts b/spec/operators/bufferTime-spec.ts index bb86409c87..b3f729e248 100644 --- a/spec/operators/bufferTime-spec.ts +++ b/spec/operators/bufferTime-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/bufferToggle-spec.ts b/spec/operators/bufferToggle-spec.ts index 02da0ec509..2f54785a21 100644 --- a/spec/operators/bufferToggle-spec.ts +++ b/spec/operators/bufferToggle-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/bufferWhen-spec.ts b/spec/operators/bufferWhen-spec.ts index 1abc095d06..d42b7f0a0c 100644 --- a/spec/operators/bufferWhen-spec.ts +++ b/spec/operators/bufferWhen-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/catch-spec.ts b/spec/operators/catch-spec.ts index fe707c834c..22996203b8 100644 --- a/spec/operators/catch-spec.ts +++ b/spec/operators/catch-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import * as sinon from 'sinon'; import { createObservableInputs } from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/operators/combineAll-spec.ts b/spec/operators/combineAll-spec.ts index a00f6ce64f..e30227e6f9 100644 --- a/spec/operators/combineAll-spec.ts +++ b/spec/operators/combineAll-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/combineLatest-spec.ts b/spec/operators/combineLatest-spec.ts index 7510fee2f0..b4c942c870 100644 --- a/spec/operators/combineLatest-spec.ts +++ b/spec/operators/combineLatest-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/concat-spec.ts b/spec/operators/concat-spec.ts index 3fc571e69d..c6d6681b29 100644 --- a/spec/operators/concat-spec.ts +++ b/spec/operators/concat-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/concatAll-spec.ts b/spec/operators/concatAll-spec.ts index cb3430198e..616c395e42 100644 --- a/spec/operators/concatAll-spec.ts +++ b/spec/operators/concatAll-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/concatMap-spec.ts b/spec/operators/concatMap-spec.ts index e74d6d1eaa..f0216973fd 100644 --- a/spec/operators/concatMap-spec.ts +++ b/spec/operators/concatMap-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/concatMapTo-spec.ts b/spec/operators/concatMapTo-spec.ts index e30f396b06..00fed8d222 100644 --- a/spec/operators/concatMapTo-spec.ts +++ b/spec/operators/concatMapTo-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/count-spec.ts b/spec/operators/count-spec.ts index 43b0c82a4c..afa813659e 100644 --- a/spec/operators/count-spec.ts +++ b/spec/operators/count-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/debounce-spec.ts b/spec/operators/debounce-spec.ts index 45d4fef21b..20e6079089 100644 --- a/spec/operators/debounce-spec.ts +++ b/spec/operators/debounce-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/debounceTime-spec.ts b/spec/operators/debounceTime-spec.ts index 02ed83d5d1..693469d803 100644 --- a/spec/operators/debounceTime-spec.ts +++ b/spec/operators/debounceTime-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/defaultIfEmpty-spec.ts b/spec/operators/defaultIfEmpty-spec.ts index 39a623ee06..d591d64b3a 100644 --- a/spec/operators/defaultIfEmpty-spec.ts +++ b/spec/operators/defaultIfEmpty-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/delay-spec.ts b/spec/operators/delay-spec.ts index 499a24d846..40c4008da4 100644 --- a/spec/operators/delay-spec.ts +++ b/spec/operators/delay-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/delayWhen-spec.ts b/spec/operators/delayWhen-spec.ts index 0e5388bf34..e666b7f95a 100644 --- a/spec/operators/delayWhen-spec.ts +++ b/spec/operators/delayWhen-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports import { expect } from 'chai'; diff --git a/spec/operators/dematerialize-spec.ts b/spec/operators/dematerialize-spec.ts index 88974ef063..4feef72ecd 100644 --- a/spec/operators/dematerialize-spec.ts +++ b/spec/operators/dematerialize-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/distinct-spec.ts b/spec/operators/distinct-spec.ts index a8996944a0..8cae1d7415 100644 --- a/spec/operators/distinct-spec.ts +++ b/spec/operators/distinct-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/operators/distinctUntilChanged-spec.ts b/spec/operators/distinctUntilChanged-spec.ts index 2337f5cf87..50875f6003 100644 --- a/spec/operators/distinctUntilChanged-spec.ts +++ b/spec/operators/distinctUntilChanged-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/distinctUntilKeyChanged-spec.ts b/spec/operators/distinctUntilKeyChanged-spec.ts index 1adb93a2ce..4d537298a8 100644 --- a/spec/operators/distinctUntilKeyChanged-spec.ts +++ b/spec/operators/distinctUntilKeyChanged-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/do-spec.ts b/spec/operators/do-spec.ts index 552c381535..2c22d7f488 100644 --- a/spec/operators/do-spec.ts +++ b/spec/operators/do-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/elementAt-spec.ts b/spec/operators/elementAt-spec.ts index e93968eadd..f302ea0bd1 100644 --- a/spec/operators/elementAt-spec.ts +++ b/spec/operators/elementAt-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/every-spec.ts b/spec/operators/every-spec.ts index 65674db90e..f80a113715 100644 --- a/spec/operators/every-spec.ts +++ b/spec/operators/every-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/exhaust-spec.ts b/spec/operators/exhaust-spec.ts index 68d918137d..cc36ffc204 100644 --- a/spec/operators/exhaust-spec.ts +++ b/spec/operators/exhaust-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/exhaustMap-spec.ts b/spec/operators/exhaustMap-spec.ts index 696b4854df..2fca97bd83 100644 --- a/spec/operators/exhaustMap-spec.ts +++ b/spec/operators/exhaustMap-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/expand-spec.ts b/spec/operators/expand-spec.ts index ec9628c5e4..49e3af0455 100644 --- a/spec/operators/expand-spec.ts +++ b/spec/operators/expand-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/filter-spec.ts b/spec/operators/filter-spec.ts index 6eb3be68d9..4bd95b0f2e 100644 --- a/spec/operators/filter-spec.ts +++ b/spec/operators/filter-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/finally-spec.ts b/spec/operators/finally-spec.ts index 9614e6e58a..33b3ffc206 100644 --- a/spec/operators/finally-spec.ts +++ b/spec/operators/finally-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, Symbol, type }; diff --git a/spec/operators/find-spec.ts b/spec/operators/find-spec.ts index cb503e8e02..6ebdcb696c 100644 --- a/spec/operators/find-spec.ts +++ b/spec/operators/find-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/findIndex-spec.ts b/spec/operators/findIndex-spec.ts index 656314f312..dba420e589 100644 --- a/spec/operators/findIndex-spec.ts +++ b/spec/operators/findIndex-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/first-spec.ts b/spec/operators/first-spec.ts index b5c46768a9..8e4fdedb65 100644 --- a/spec/operators/first-spec.ts +++ b/spec/operators/first-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/groupBy-spec.ts b/spec/operators/groupBy-spec.ts index 5adf98abd5..5ff73a913e 100644 --- a/spec/operators/groupBy-spec.ts +++ b/spec/operators/groupBy-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { GroupedObservable } from '../../dist/package/operators/groupBy'; +import * as Rx from '../../src/Rx'; +import { GroupedObservable } from '../../src/operators/groupBy'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/ignoreElements-spec.ts b/spec/operators/ignoreElements-spec.ts index 71a9e052cc..8ab327cb7d 100644 --- a/spec/operators/ignoreElements-spec.ts +++ b/spec/operators/ignoreElements-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/isEmpty-spec.ts b/spec/operators/isEmpty-spec.ts index 5a38d5fecc..262896383b 100644 --- a/spec/operators/isEmpty-spec.ts +++ b/spec/operators/isEmpty-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/last-spec.ts b/spec/operators/last-spec.ts index b170997ec6..131b0149b0 100644 --- a/spec/operators/last-spec.ts +++ b/spec/operators/last-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/let-spec.ts b/spec/operators/let-spec.ts index 2142176a31..672dfc782b 100644 --- a/spec/operators/let-spec.ts +++ b/spec/operators/let-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; /** @test {let} */ describe('Observable.prototype.let', () => { diff --git a/spec/operators/map-spec.ts b/spec/operators/map-spec.ts index 100cc1a386..5b23d44735 100644 --- a/spec/operators/map-spec.ts +++ b/spec/operators/map-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/mapTo-spec.ts b/spec/operators/mapTo-spec.ts index bc61af8aab..b270d3b1db 100644 --- a/spec/operators/mapTo-spec.ts +++ b/spec/operators/mapTo-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/materialize-spec.ts b/spec/operators/materialize-spec.ts index 2dd0211f5f..fb2c95ab6a 100644 --- a/spec/operators/materialize-spec.ts +++ b/spec/operators/materialize-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/max-spec.ts b/spec/operators/max-spec.ts index c1753f609d..b8f995aab8 100644 --- a/spec/operators/max-spec.ts +++ b/spec/operators/max-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/merge-spec.ts b/spec/operators/merge-spec.ts index aa8d5e3200..fdcc56e823 100644 --- a/spec/operators/merge-spec.ts +++ b/spec/operators/merge-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/mergeAll-spec.ts b/spec/operators/mergeAll-spec.ts index 60c0507b8f..32654a18b0 100644 --- a/spec/operators/mergeAll-spec.ts +++ b/spec/operators/mergeAll-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/mergeMap-spec.ts b/spec/operators/mergeMap-spec.ts index 8bd3254a5d..4db8cab7ad 100644 --- a/spec/operators/mergeMap-spec.ts +++ b/spec/operators/mergeMap-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, type }; diff --git a/spec/operators/mergeMapTo-spec.ts b/spec/operators/mergeMapTo-spec.ts index d3695b775a..fef41e0a97 100644 --- a/spec/operators/mergeMapTo-spec.ts +++ b/spec/operators/mergeMapTo-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, type }; diff --git a/spec/operators/mergeScan-spec.ts b/spec/operators/mergeScan-spec.ts index 9c1cbf336d..90194db1ff 100644 --- a/spec/operators/mergeScan-spec.ts +++ b/spec/operators/mergeScan-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/operators/min-spec.ts b/spec/operators/min-spec.ts index 45b8d721d6..29555ebbe3 100644 --- a/spec/operators/min-spec.ts +++ b/spec/operators/min-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/multicast-spec.ts b/spec/operators/multicast-spec.ts index cdcfd2d739..164925138c 100644 --- a/spec/operators/multicast-spec.ts +++ b/spec/operators/multicast-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time, rxTestScheduler }; diff --git a/spec/operators/observeOn-spec.ts b/spec/operators/observeOn-spec.ts index 862b4c5d14..dcc181b917 100644 --- a/spec/operators/observeOn-spec.ts +++ b/spec/operators/observeOn-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { expect } from 'chai'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/operators/onErrorResumeNext-spec.ts b/spec/operators/onErrorResumeNext-spec.ts index 77d9fa9b5c..86ced33081 100644 --- a/spec/operators/onErrorResumeNext-spec.ts +++ b/spec/operators/onErrorResumeNext-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/partition-spec.ts b/spec/operators/partition-spec.ts index 6d1c0877a4..000e4c36fa 100644 --- a/spec/operators/partition-spec.ts +++ b/spec/operators/partition-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/pluck-spec.ts b/spec/operators/pluck-spec.ts index 2b554c1376..391958192b 100644 --- a/spec/operators/pluck-spec.ts +++ b/spec/operators/pluck-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/publish-spec.ts b/spec/operators/publish-spec.ts index 075d769651..97eb079359 100644 --- a/spec/operators/publish-spec.ts +++ b/spec/operators/publish-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/publishBehavior-spec.ts b/spec/operators/publishBehavior-spec.ts index 4f6337e8d5..c69234aee9 100644 --- a/spec/operators/publishBehavior-spec.ts +++ b/spec/operators/publishBehavior-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/publishLast-spec.ts b/spec/operators/publishLast-spec.ts index 8c03d3b2f9..3b37ee5c84 100644 --- a/spec/operators/publishLast-spec.ts +++ b/spec/operators/publishLast-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/publishReplay-spec.ts b/spec/operators/publishReplay-spec.ts index 5b6c9ace8a..a15c9bb88a 100644 --- a/spec/operators/publishReplay-spec.ts +++ b/spec/operators/publishReplay-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/race-spec.ts b/spec/operators/race-spec.ts index 1c51ce1d53..24256c0e85 100644 --- a/spec/operators/race-spec.ts +++ b/spec/operators/race-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/operators/reduce-spec.ts b/spec/operators/reduce-spec.ts index 85a6ecf77f..f88f010444 100644 --- a/spec/operators/reduce-spec.ts +++ b/spec/operators/reduce-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, type }; diff --git a/spec/operators/refCount-spec.ts b/spec/operators/refCount-spec.ts index b3996fcf85..4f88056c19 100644 --- a/spec/operators/refCount-spec.ts +++ b/spec/operators/refCount-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/repeat-spec.ts b/spec/operators/repeat-spec.ts index 3f177fc616..a4dcd95d7d 100644 --- a/spec/operators/repeat-spec.ts +++ b/spec/operators/repeat-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/repeatWhen-spec.ts b/spec/operators/repeatWhen-spec.ts index fb233d8fbd..6d1cfa321e 100644 --- a/spec/operators/repeatWhen-spec.ts +++ b/spec/operators/repeatWhen-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/retry-spec.ts b/spec/operators/retry-spec.ts index bce76d3ae1..e151cdf6bd 100644 --- a/spec/operators/retry-spec.ts +++ b/spec/operators/retry-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/retryWhen-spec.ts b/spec/operators/retryWhen-spec.ts index 8ee4a658ad..0e8767861a 100644 --- a/spec/operators/retryWhen-spec.ts +++ b/spec/operators/retryWhen-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/sample-spec.ts b/spec/operators/sample-spec.ts index 32b225bfdf..b2666ccd46 100644 --- a/spec/operators/sample-spec.ts +++ b/spec/operators/sample-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { expect } from 'chai'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/operators/sampleTime-spec.ts b/spec/operators/sampleTime-spec.ts index 627214cd90..c05be93d07 100644 --- a/spec/operators/sampleTime-spec.ts +++ b/spec/operators/sampleTime-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/scan-spec.ts b/spec/operators/scan-spec.ts index 6f98f0d21e..c55f6a45a9 100644 --- a/spec/operators/scan-spec.ts +++ b/spec/operators/scan-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, type }; diff --git a/spec/operators/share-spec.ts b/spec/operators/share-spec.ts index a66a7c573e..499977a5bf 100644 --- a/spec/operators/share-spec.ts +++ b/spec/operators/share-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/shareReplay-spec.ts b/spec/operators/shareReplay-spec.ts index 740f5f5840..91d6d0d184 100644 --- a/spec/operators/shareReplay-spec.ts +++ b/spec/operators/shareReplay-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/single-spec.ts b/spec/operators/single-spec.ts index aa999fb37a..3ff97b715d 100644 --- a/spec/operators/single-spec.ts +++ b/spec/operators/single-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/skip-spec.ts b/spec/operators/skip-spec.ts index 48043e88ae..1b0a3f02c1 100644 --- a/spec/operators/skip-spec.ts +++ b/spec/operators/skip-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/skipLast-spec.ts b/spec/operators/skipLast-spec.ts index 6a740a0827..ffdb61afd9 100644 --- a/spec/operators/skipLast-spec.ts +++ b/spec/operators/skipLast-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/skipUntil-spec.ts b/spec/operators/skipUntil-spec.ts index 2f2ba0d8e2..6b849cdeae 100644 --- a/spec/operators/skipUntil-spec.ts +++ b/spec/operators/skipUntil-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/skipWhile-spec.ts b/spec/operators/skipWhile-spec.ts index 888c5ab0d1..68330ed827 100644 --- a/spec/operators/skipWhile-spec.ts +++ b/spec/operators/skipWhile-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/startWith-spec.ts b/spec/operators/startWith-spec.ts index 7428fe82df..57d0522460 100644 --- a/spec/operators/startWith-spec.ts +++ b/spec/operators/startWith-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/subscribeOn-spec.ts b/spec/operators/subscribeOn-spec.ts index dfee14f8ad..3924fc12eb 100644 --- a/spec/operators/subscribeOn-spec.ts +++ b/spec/operators/subscribeOn-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/switch-spec.ts b/spec/operators/switch-spec.ts index 4baac194db..bcafd1d257 100644 --- a/spec/operators/switch-spec.ts +++ b/spec/operators/switch-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/switchMap-spec.ts b/spec/operators/switchMap-spec.ts index 0313e81575..ef9b47042d 100644 --- a/spec/operators/switchMap-spec.ts +++ b/spec/operators/switchMap-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/switchMapTo-spec.ts b/spec/operators/switchMapTo-spec.ts index ac9c9bfeee..1e3135002d 100644 --- a/spec/operators/switchMapTo-spec.ts +++ b/spec/operators/switchMapTo-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/take-spec.ts b/spec/operators/take-spec.ts index f193443173..1f05045720 100644 --- a/spec/operators/take-spec.ts +++ b/spec/operators/take-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/takeLast-spec.ts b/spec/operators/takeLast-spec.ts index f7f113151e..03cb72ab0a 100644 --- a/spec/operators/takeLast-spec.ts +++ b/spec/operators/takeLast-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/takeUntil-spec.ts b/spec/operators/takeUntil-spec.ts index 00ad8d7649..0e438ef2b0 100644 --- a/spec/operators/takeUntil-spec.ts +++ b/spec/operators/takeUntil-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/takeWhile-spec.ts b/spec/operators/takeWhile-spec.ts index 671a2190ab..47733ea284 100644 --- a/spec/operators/takeWhile-spec.ts +++ b/spec/operators/takeWhile-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/throttle-spec.ts b/spec/operators/throttle-spec.ts index 06e1d9bc13..7bdce50eec 100644 --- a/spec/operators/throttle-spec.ts +++ b/spec/operators/throttle-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/throttleTime-spec.ts b/spec/operators/throttleTime-spec.ts index e668c9b9c7..6b8d93cb7f 100644 --- a/spec/operators/throttleTime-spec.ts +++ b/spec/operators/throttleTime-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/timeInterval-spec.ts b/spec/operators/timeInterval-spec.ts index 4bc663d613..2c36658239 100644 --- a/spec/operators/timeInterval-spec.ts +++ b/spec/operators/timeInterval-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/timeout-spec.ts b/spec/operators/timeout-spec.ts index 6b1c2469a8..60e1c66107 100644 --- a/spec/operators/timeout-spec.ts +++ b/spec/operators/timeout-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/timeoutWith-spec.ts b/spec/operators/timeoutWith-spec.ts index 89518fa6bf..ee203b6e4a 100644 --- a/spec/operators/timeoutWith-spec.ts +++ b/spec/operators/timeoutWith-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/timestamp-spec.ts b/spec/operators/timestamp-spec.ts index f94a46f9dd..b324546dae 100644 --- a/spec/operators/timestamp-spec.ts +++ b/spec/operators/timestamp-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/operators/toArray-spec.ts b/spec/operators/toArray-spec.ts index 1338970a36..259a50b263 100644 --- a/spec/operators/toArray-spec.ts +++ b/spec/operators/toArray-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, type }; diff --git a/spec/operators/toPromise-spec.ts b/spec/operators/toPromise-spec.ts index 3a38ffac25..3cabdf8a9e 100644 --- a/spec/operators/toPromise-spec.ts +++ b/spec/operators/toPromise-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; declare const __root__: any; const Observable = Rx.Observable; diff --git a/spec/operators/window-spec.ts b/spec/operators/window-spec.ts index a131f6490f..312c96c854 100644 --- a/spec/operators/window-spec.ts +++ b/spec/operators/window-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/windowCount-spec.ts b/spec/operators/windowCount-spec.ts index 1801f27d32..8691759b82 100644 --- a/spec/operators/windowCount-spec.ts +++ b/spec/operators/windowCount-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/windowTime-spec.ts b/spec/operators/windowTime-spec.ts index 6f2e6362f2..d632a65de0 100644 --- a/spec/operators/windowTime-spec.ts +++ b/spec/operators/windowTime-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/windowToggle-spec.ts b/spec/operators/windowToggle-spec.ts index 8b04577cf3..7184a0e2b4 100644 --- a/spec/operators/windowToggle-spec.ts +++ b/spec/operators/windowToggle-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/windowWhen-spec.ts b/spec/operators/windowWhen-spec.ts index 0fdd7882d1..5e6f0832d9 100644 --- a/spec/operators/windowWhen-spec.ts +++ b/spec/operators/windowWhen-spec.ts @@ -1,4 +1,4 @@ -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram, time }; diff --git a/spec/operators/withLatestFrom-spec.ts b/spec/operators/withLatestFrom-spec.ts index 3cdd5106fc..7e98d5cc44 100644 --- a/spec/operators/withLatestFrom-spec.ts +++ b/spec/operators/withLatestFrom-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import { lowerCaseO } from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports diff --git a/spec/operators/zip-spec.ts b/spec/operators/zip-spec.ts index ab3852a0b8..c6d779afa5 100644 --- a/spec/operators/zip-spec.ts +++ b/spec/operators/zip-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const type; diff --git a/spec/operators/zipAll-spec.ts b/spec/operators/zipAll-spec.ts index 011ee2131d..468ae62885 100644 --- a/spec/operators/zipAll-spec.ts +++ b/spec/operators/zipAll-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { asDiagram }; diff --git a/spec/root-module-spec.ts b/spec/root-module-spec.ts index e344725781..ef9926e6b1 100644 --- a/spec/root-module-spec.ts +++ b/spec/root-module-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../dist/package/Rx'; +import * as Rx from '../src/Rx'; describe('Root Module', () => { it('should contain exports from commonjs modules', () => { diff --git a/spec/schedulers/AnimationFrameScheduler-spec.ts b/spec/schedulers/AnimationFrameScheduler-spec.ts index f29fff5034..5a630c6ce0 100644 --- a/spec/schedulers/AnimationFrameScheduler-spec.ts +++ b/spec/schedulers/AnimationFrameScheduler-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const animationFrame = Rx.Scheduler.animationFrame; diff --git a/spec/schedulers/AsapScheduler-spec.ts b/spec/schedulers/AsapScheduler-spec.ts index 1428dfb2be..91a5c1be3e 100644 --- a/spec/schedulers/AsapScheduler-spec.ts +++ b/spec/schedulers/AsapScheduler-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const asap = Rx.Scheduler.asap; diff --git a/spec/schedulers/QueueScheduler-spec.ts b/spec/schedulers/QueueScheduler-spec.ts index 6543f65e80..154346ba1c 100644 --- a/spec/schedulers/QueueScheduler-spec.ts +++ b/spec/schedulers/QueueScheduler-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const Scheduler = Rx.Scheduler; const queue = Scheduler.queue; diff --git a/spec/schedulers/TestScheduler-spec.ts b/spec/schedulers/TestScheduler-spec.ts index 550d33cab1..9ee546324f 100644 --- a/spec/schedulers/TestScheduler-spec.ts +++ b/spec/schedulers/TestScheduler-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { time }; diff --git a/spec/schedulers/VirtualTimeScheduler-spec.ts b/spec/schedulers/VirtualTimeScheduler-spec.ts index 0f99daa7b0..45deffa426 100644 --- a/spec/schedulers/VirtualTimeScheduler-spec.ts +++ b/spec/schedulers/VirtualTimeScheduler-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { VirtualAction } from '../../dist/package/scheduler/VirtualTimeScheduler'; +import * as Rx from '../../src/Rx'; +import { VirtualAction } from '../../src/scheduler/VirtualTimeScheduler'; const VirtualTimeScheduler = Rx.VirtualTimeScheduler; diff --git a/spec/subjects/AsyncSubject-spec.ts b/spec/subjects/AsyncSubject-spec.ts index 9f06623af9..01dfea091f 100644 --- a/spec/subjects/AsyncSubject-spec.ts +++ b/spec/subjects/AsyncSubject-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const AsyncSubject = Rx.AsyncSubject; diff --git a/spec/subjects/BehaviorSubject-spec.ts b/spec/subjects/BehaviorSubject-spec.ts index 6b0d8bc5f5..638569d17b 100644 --- a/spec/subjects/BehaviorSubject-spec.ts +++ b/spec/subjects/BehaviorSubject-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const { time }; diff --git a/spec/subjects/ReplaySubject-spec.ts b/spec/subjects/ReplaySubject-spec.ts index 933943ff60..9e774800e0 100644 --- a/spec/subjects/ReplaySubject-spec.ts +++ b/spec/subjects/ReplaySubject-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { TestScheduler } from '../../dist/package/testing/TestScheduler'; +import * as Rx from '../../src/Rx'; +import { TestScheduler } from '../../src/testing/TestScheduler'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; diff --git a/spec/support/debug.opts b/spec/support/debug.opts deleted file mode 100644 index 2287c7690a..0000000000 --- a/spec/support/debug.opts +++ /dev/null @@ -1,12 +0,0 @@ ---require source-map-support/register ---require spec-js/helpers/testScheduler-ui.js ---ui spec-js/helpers/testScheduler-ui.js - ---reporter dot ---bail ---full-trace ---check-leaks ---globals WebSocket,FormData,XDomainRequest,ActiveXObject - ---recursive ---timeout 100000 diff --git a/spec/support/default.opts b/spec/support/default.opts index f24cb86f54..419ffe734d 100644 --- a/spec/support/default.opts +++ b/spec/support/default.opts @@ -1,6 +1,6 @@ --require source-map-support/register ---require spec-js/helpers/testScheduler-ui.js ---ui spec-js/helpers/testScheduler-ui.js +--require .out/spec/helpers/testScheduler-ui.js +--ui .out/spec/helpers/testScheduler-ui.js --reporter dot diff --git a/spec/symbol/iterator-spec.ts b/spec/symbol/iterator-spec.ts index 9fa1e4ea5e..d1f0bbfaa9 100644 --- a/spec/symbol/iterator-spec.ts +++ b/spec/symbol/iterator-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { $$iterator, symbolIteratorPonyfill } from '../../dist/package/symbol/iterator'; +import { $$iterator, symbolIteratorPonyfill } from '../../src/symbol/iterator'; describe('iterator symbol', () => { it('should exist', () => { diff --git a/spec/symbol/observable-polyfilled-spec.ts b/spec/symbol/observable-polyfilled-spec.ts index fa7989c812..c6dfa7bbf9 100644 --- a/spec/symbol/observable-polyfilled-spec.ts +++ b/spec/symbol/observable-polyfilled-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { getSymbolObservable } from '../../dist/package/symbol/observable'; +import { getSymbolObservable } from '../../src/symbol/observable'; describe('observable symbol', () => { it('should exist in the proper form when Symbol does not exist', () => { diff --git a/spec/symbol/observable-spec.ts b/spec/symbol/observable-spec.ts index f86ca58af4..6c2d502b77 100644 --- a/spec/symbol/observable-spec.ts +++ b/spec/symbol/observable-spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; import $$symbolObservable from 'symbol-observable'; -import { root } from '../../dist/package/util/root'; -import { getSymbolObservable } from '../../dist/package/symbol/observable'; +import { root } from '../../src/util/root'; +import { getSymbolObservable } from '../../src/symbol/observable'; describe('observable symbol', () => { it('should exist in the proper form', () => { diff --git a/spec/symbol/rxSubscriber-spec.ts b/spec/symbol/rxSubscriber-spec.ts index 573a78d99a..b5e793be0d 100644 --- a/spec/symbol/rxSubscriber-spec.ts +++ b/spec/symbol/rxSubscriber-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { root } from '../../dist/package/util/root'; -import {$$rxSubscriber} from '../../dist/package/symbol/rxSubscriber'; +import { root } from '../../src/util/root'; +import {$$rxSubscriber} from '../../src/symbol/rxSubscriber'; describe('rxSubscriber symbol', () => { it('should exist in the proper form', () => { diff --git a/spec/util/FastMap-spec.ts b/spec/util/FastMap-spec.ts index 7cf68a51ee..a9b8c520c6 100644 --- a/spec/util/FastMap-spec.ts +++ b/spec/util/FastMap-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { FastMap } from '../../dist/package/util/FastMap'; +import { FastMap } from '../../src/util/FastMap'; /** @test {FastMap} */ describe('FastMap', () => { diff --git a/spec/util/Immediate-spec.ts b/spec/util/Immediate-spec.ts index 7528a7d474..8c8eaea432 100644 --- a/spec/util/Immediate-spec.ts +++ b/spec/util/Immediate-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as sinon from 'sinon'; -import { ImmediateDefinition } from '../../dist/package/util/Immediate'; -import * as Rx from '../../dist/package/Rx'; +import { ImmediateDefinition } from '../../src/util/Immediate'; +import * as Rx from '../../src/Rx'; declare const __root__: any; diff --git a/spec/util/MapPolyfill-spec.ts b/spec/util/MapPolyfill-spec.ts index e165232793..2fcc33fffd 100644 --- a/spec/util/MapPolyfill-spec.ts +++ b/spec/util/MapPolyfill-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { MapPolyfill } from '../../dist/package/util/MapPolyfill'; +import { MapPolyfill } from '../../src/util/MapPolyfill'; /** @test {MapPolyfill} */ describe('MapPolyfill', () => { diff --git a/spec/util/Set-spec.ts b/spec/util/Set-spec.ts index 80623f7612..747e03678a 100644 --- a/spec/util/Set-spec.ts +++ b/spec/util/Set-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { Set as TestSet, minimalSetImpl } from '../../dist/package/util/Set'; +import { Set as TestSet, minimalSetImpl } from '../../src/util/Set'; describe('Set', () => { if (typeof Set === 'function') { diff --git a/spec/util/UnsubscriptionError-spec.ts b/spec/util/UnsubscriptionError-spec.ts index 4736f9ccca..dad0143705 100644 --- a/spec/util/UnsubscriptionError-spec.ts +++ b/spec/util/UnsubscriptionError-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; +import * as Rx from '../../src/Rx'; const { Observable, UnsubscriptionError } = Rx; diff --git a/spec/util/assign-spec.ts b/spec/util/assign-spec.ts index 537f2dff09..34c735f715 100644 --- a/spec/util/assign-spec.ts +++ b/spec/util/assign-spec.ts @@ -1,14 +1,14 @@ import { expect } from 'chai'; -import { assign, getAssign, assignImpl } from '../../dist/package/util/assign'; +import { assign, getAssign, assignImpl } from '../../src/util/assign'; describe('assign', () => { it('should exist', () => { expect(assign).to.be.a('function'); }); - if (Object.assign) { + if ((Object as any).assign) { it('should use Object.assign if available', () => { - expect(assign).to.equal(Object.assign); + expect(assign).to.equal(((Object as any).assign)); }); } diff --git a/spec/util/pipe-spec.ts b/spec/util/pipe-spec.ts index 37c6c083b4..755ef3c76a 100644 --- a/spec/util/pipe-spec.ts +++ b/spec/util/pipe-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { pipe } from '../../dist/package/util/pipe'; +import { pipe } from '../../src/util/pipe'; describe('pipe', () => { it('should exist', () => { diff --git a/spec/util/root-spec.ts b/spec/util/root-spec.ts index 9891483a90..a6c1c58709 100644 --- a/spec/util/root-spec.ts +++ b/spec/util/root-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { root } from '../../dist/package/util/root'; +import { root } from '../../src/util/root'; /** @test {root} */ describe('root', () => { diff --git a/spec/util/subscribeToResult-spec.ts b/spec/util/subscribeToResult-spec.ts index 6972dbceba..d7810c587c 100644 --- a/spec/util/subscribeToResult-spec.ts +++ b/spec/util/subscribeToResult-spec.ts @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import * as Rx from '../../dist/package/Rx'; -import { subscribeToResult } from '../../dist/package/util/subscribeToResult'; -import { OuterSubscriber } from '../../dist/package/OuterSubscriber'; -import { $$iterator } from '../../dist/package/symbol/iterator'; +import * as Rx from '../../src/Rx'; +import { subscribeToResult } from '../../src/util/subscribeToResult'; +import { OuterSubscriber } from '../../src/OuterSubscriber'; +import { $$iterator } from '../../src/symbol/iterator'; import $$symbolObservable from 'symbol-observable'; -import { Observable } from '../../dist/package/Observable'; -import { Subject } from '../../dist/package/Subject'; +import { Observable } from '../../src/Observable'; +import { Subject } from '../../src/Subject'; describe('subscribeToResult', () => { it('should synchronously complete when subscribe to scalarObservable', () => { diff --git a/spec/util/toSubscriber-spec.ts b/spec/util/toSubscriber-spec.ts index e275bf76c4..c285bc56f6 100644 --- a/spec/util/toSubscriber-spec.ts +++ b/spec/util/toSubscriber-spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { toSubscriber } from '../../dist/package/util/toSubscriber'; +import { toSubscriber } from '../../src/util/toSubscriber'; describe('toSubscriber', () => { it('should not be closed when other subscriber created with no arguments completes', () => { From 01bc30cf0bb021ef3579f19b5f7a684b85520d0f Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 22 Sep 2017 22:40:25 -0700 Subject: [PATCH 05/77] chore(package): update test scripts --- package.json | 36 +++++++++++++++++++++--------------- wallaby.js | 14 ++------------ 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index b1abf9ca59..398b6fc52f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,19 @@ "path": "cz-conventional-changelog" } }, + "nyc": { + "exclude": [ + "node_modules", + "typings", + "*.d.ts", + "src/MiscJSDoc.ts", + "**/spec/**/*" + ], + "reporter": [ + "json", + "html" + ] + }, "lint-staged": { "*.@(js)": [ "eslint --fix", @@ -28,11 +41,9 @@ "build_global": "Build Global package, then minify build", "build_perf": "Build CJS & Global build, run macro performance test", "build_test": "Build CJS package & test spec, execute mocha test runner", - "build_cover": "Run lint to current code, build CJS & test spec, execute test coverage", "build_docs": "Build ESM2015 & global package, create documentation using it", "build_spec": "Build test specs", "check_circular_dependencies": "Check codebase has circular dependencies", - "clean_spec": "Clean up existing test spec build output", "clean_dist_cjs": "Clean up existing CJS package output", "clean_dist_esm5": "Clean up existing ESM/ES5 package output", "clean_dist_esm2015": "Clean up existing ESM/ES2015 package output", @@ -68,13 +79,10 @@ "build_global": "npm-run-all clean_dist_global build_esm5_for_rollup && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core clean_dist_esm5_for_rollup", "build_umd": "npm-run-all clean_dist_global && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core", "build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf", - "build_test": "shx rm -rf ./dist/ && npm-run-all copy_sources build_cjs generate_packages clean_spec build_spec test_mocha", - "build_cover": "shx rm -rf ./dist/ && npm-run-all build_all build_spec cover", - "build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs clean_spec build_spec tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015", + "build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs build_spec tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015", "build_spec": "tsc --project ./spec --pretty", "build_spec_browser": "webpack --config spec/support/webpack.mocha.config.js", "check_circular_dependencies": "madge ./dist/cjs --circular", - "clean_spec": "shx rm -rf spec-js", "clean_dist": "shx rm -rf ./dist", "clean_dist_cjs": "shx rm -rf ./dist/cjs", "clean_dist_esm5": "shx rm -rf ./dist/esm5", @@ -82,12 +90,12 @@ "clean_dist_esm2015": "shx rm -rf ./dist/esm2015", "clean_dist_global": "shx rm -rf ./dist/global", "commit": "git-cz", - "compile_dist_cjs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --inlineSources --outDir ./dist/cjs --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node -d --declarationDir ./dist/typings", - "compile_dist_esm5": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5 --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", - "compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", - "compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts ./dist/src/operator/toPromise.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", - "compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers", - "copy_sources": "mkdirp dist && shx cp -r ./src/ ./dist/src", + "compile_dist_cjs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/cjs --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node -d --declarationDir ./dist/typings", + "compile_dist_esm5": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5 --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", + "compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", + "compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", + "compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers", + "copy_sources": "mkdir -p dist && rsync -a ./src/ ./dist/src", "cover": "shx rm -rf dist/cjs && tsc dist/src/Rx.ts dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* --exclude=node_modules mocha --opts spec/support/default.opts spec-js", "decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..", "doctoc": "doctoc CONTRIBUTING.md", @@ -100,10 +108,8 @@ "perf_micro": "node ./perf/micro/index.js", "prepublish": "shx rm -rf ./typings && typings install && npm run build_all", "publish_docs": "./publish_docs.sh", - "test_mocha": "mocha --opts spec/support/default.opts spec-js", - "debug_mocha": "node --inspect --debug-brk ./node_modules/.bin/_mocha --opts spec/support/debug.opts spec-js", "test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html", - "test": "npm-run-all clean_spec build_spec test_mocha clean_spec", + "test": "shx rm -rf ./.out && tsc && mocha --opts spec/support/default.opts ./.out/spec/**/*-spec.js", "tests2png": "npm run build_spec && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js", "watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15" }, diff --git a/wallaby.js b/wallaby.js index b385c51402..5eb103f06a 100644 --- a/wallaby.js +++ b/wallaby.js @@ -1,7 +1,7 @@ module.exports = wallaby => ({ files: [ 'src/**/*.ts', - {pattern: 'spec/helpers/*.ts', instrument: false} + { pattern: 'spec/helpers/*.ts', instrument: false } ], tests: ['spec/**/*-spec.ts'], @@ -23,19 +23,9 @@ module.exports = wallaby => ({ type: 'node' }, - workers: {initial: 1, regular: 1}, + workers: { initial: 1, regular: 1 }, bootstrap: function (w) { - // Remapping all require calls to `dist/cjs` right to `src` - const Module = require('module').Module; - if (!Module._originalRequire) { - const modulePrototype = Module.prototype; - Module._originalRequire = modulePrototype.require; - modulePrototype.require = function (filePath) { - return Module._originalRequire.call(this, filePath.replace('dist/cjs', 'src')); - }; - } - // Global test helpers global.mocha = require('mocha'); global.Suite = global.mocha.Suite; From 4d74d06396d208adea6eeddb8589a0f3aa3b4af7 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 22 Sep 2017 22:41:05 -0700 Subject: [PATCH 06/77] chore(travis): update travis configuration --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 03890517e4..c000315f7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ install: script: - if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then echo {} > ./.babelrc && npx danger; fi - - npm run build_spec && npm run test_mocha && node ./node_modules/markdown-doctest/bin/cmd.js + - npm test after_success: - if [ "$FULL_VALIDATE" == "true" ]; then npm run cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi From ff92a4d1d271a0824958406096d5ad5b17144576 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 22 Sep 2017 22:41:32 -0700 Subject: [PATCH 07/77] build(tsconfig): update build configuration --- .gitignore | 1 + spec/tsconfig.json | 31 ------------------------------- tsconfig.json | 12 ++++-------- 3 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 spec/tsconfig.json diff --git a/.gitignore b/.gitignore index c85060c547..9ca5ce215d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ coverage/ img/ spec-js/ .nyc_output/ +.out/ # Misc npm-debug.log diff --git a/spec/tsconfig.json b/spec/tsconfig.json deleted file mode 100644 index 5ff1c0faee..0000000000 --- a/spec/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "removeComments": false, - "preserveConstEnums": true, - "sourceMap": true, - "declaration": false, - "allowJs": true, - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "outDir": "../spec-js", - "lib": [ - "es5", - "es2015.core", - "es2015.collection", - "es2015.iterable", - "es2015.promise", - "dom" - ] - }, - "formatCodeOptions": { - "indentSize": 2, - "tabSize": 2 - }, - "exclude": [ - "support/mocha-setup-node.js", - "support/mocha.sauce.gruntfile.js", - "support/mocha.sauce.runner.js", - "support/webpack.mocha.config.js" - ] -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8f6585679b..82af808607 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,13 +4,12 @@ "preserveConstEnums": true, "sourceMap": true, "declaration": true, - "noImplicitAny": true, + "noImplicitAny": false, "noImplicitReturns": true, - "noImplicitThis": true, "suppressImplicitAnyIndexErrors": true, "moduleResolution": "node", - "target": "es6", - "outDir": "dist/es6", + "target": "es5", + "outDir": "./.out", "lib": [ "es5", "es2015.iterable", @@ -22,8 +21,5 @@ "formatCodeOptions": { "indentSize": 2, "tabSize": 2 - }, - "files": [ - "src/Rx.ts" - ] + } } \ No newline at end of file From 98e2f16757238c2206d24c6d534f864827423261 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 22 Sep 2017 23:48:07 -0700 Subject: [PATCH 08/77] style(tslint): update lint configuration --- tslint.json | 56 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/tslint.json b/tslint.json index 6bc29dd987..5df698b822 100644 --- a/tslint.json +++ b/tslint.json @@ -2,10 +2,19 @@ "rules": { "curly": true, "eofline": false, - "align": [true, "parameters"], + "align": [ + true, + "parameters" + ], "class-name": true, - "indent": [true, "spaces"], - "max-line-length": [true, 150], + "indent": [ + true, + "spaces" + ], + "max-line-length": [ + true, + 150 + ], "no-consecutive-blank-lines": true, "no-trailing-whitespace": true, "no-duplicate-variable": true, @@ -16,26 +25,39 @@ "no-use-before-declare": true, "no-var-requires": true, "no-require-imports": true, - "one-line": [true, + "one-line": [ + true, "check-else", "check-whitespace", - "check-open-brace"], - "quotemark": [true, + "check-open-brace" + ], + "quotemark": [ + true, "single", - "avoid-escape"], - "semicolon": [true, "always"], - "typedef-whitespace": [true, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }], - "whitespace": [true, + "avoid-escape" + ], + "semicolon": [ + true, + "always" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "import-spacing": true, + "whitespace": [ + true, "check-branch", "check-decl", "check-operator", "check-separator", - "check-type"] + "check-type" + ] } } \ No newline at end of file From d1e3f3b9183237f4d93f2a34a6c3088e6a26bb2e Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sat, 23 Sep 2017 00:10:26 -0700 Subject: [PATCH 09/77] style(From): update code lint, hint friendly --- src/observable/FromObservable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/observable/FromObservable.ts b/src/observable/FromObservable.ts index fb8e5a6806..030e70a8cd 100644 --- a/src/observable/FromObservable.ts +++ b/src/observable/FromObservable.ts @@ -2,7 +2,7 @@ import { isArray } from '../util/isArray'; import { isArrayLike } from '../util/isArrayLike'; import { isPromise } from '../util/isPromise'; import { PromiseObservable } from './PromiseObservable'; -import { IteratorObservable } from'./IteratorObservable'; +import { IteratorObservable } from './IteratorObservable'; import { ArrayObservable } from './ArrayObservable'; import { ArrayLikeObservable } from './ArrayLikeObservable'; From 07df85a090e0a9526edc33bbfdefdb986f4e83ac Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 25 Oct 2017 11:45:11 -0700 Subject: [PATCH 10/77] chore(package): update script for test coverage --- .travis.yml | 2 +- package.json | 25 ++++++++++++++++++------- spec/support/coverage.opts | 9 +++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 spec/support/coverage.opts diff --git a/.travis.yml b/.travis.yml index c000315f7c..8d8485997c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,5 +33,5 @@ script: - npm test after_success: - - if [ "$FULL_VALIDATE" == "true" ]; then npm run cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi + - if [ "$FULL_VALIDATE" == "true" ]; then npm run test:cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi - if [ "$FULL_VALIDATE" == "true" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ -n "$SAUCE_ACCESS_KEY" ]; then npm run build_spec_browser && grunt --gruntfile spec/support/mocha.sauce.gruntfile.js; fi \ No newline at end of file diff --git a/package.json b/package.json index 398b6fc52f..07b12ba50a 100644 --- a/package.json +++ b/package.json @@ -9,17 +9,27 @@ } }, "nyc": { + "include": [ + "src/*.ts", + "src/**/*.ts" + ], "exclude": [ "node_modules", "typings", "*.d.ts", - "src/MiscJSDoc.ts", - "**/spec/**/*" + "src/**/MiscJSDoc.ts" + ], + "extension": [ + ".ts" + ], + "require": [ + "ts-node/register" ], "reporter": [ "json", "html" - ] + ], + "all": true }, "lint-staged": { "*.@(js)": [ @@ -52,7 +62,6 @@ "compile_dist_cjs": "Compile codebase into CJS module", "compile_module_esm5": "Compile codebase into ESM/ES5", "compile_dist_esm2015": "Compile codebase into ESM/ES2015", - "cover": "Execute test coverage", "lint_perf": "Run lint against performance test suite", "lint_spec": "Run lint against test spec", "lint_src": "Run lint against source", @@ -62,6 +71,7 @@ "test_mocha": "Execute mocha test runner against existing test spec build", "test_browser": "Execute mocha test runner on browser against existing test spec build", "test": "Clean up existing test spec build, build test spec and execute mocha test runner", + "test:cover": "Execute test coverage", "tests2png": "Generate marble diagram image from test spec", "watch": "Watch codebase, trigger compile when source code changes" }, @@ -96,7 +106,6 @@ "compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", "compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers", "copy_sources": "mkdir -p dist && rsync -a ./src/ ./dist/src", - "cover": "shx rm -rf dist/cjs && tsc dist/src/Rx.ts dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* --exclude=node_modules mocha --opts spec/support/default.opts spec-js", "decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..", "doctoc": "doctoc CONTRIBUTING.md", "generate_packages": "node .make-packages.js", @@ -109,7 +118,8 @@ "prepublish": "shx rm -rf ./typings && typings install && npm run build_all", "publish_docs": "./publish_docs.sh", "test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html", - "test": "shx rm -rf ./.out && tsc && mocha --opts spec/support/default.opts ./.out/spec/**/*-spec.js", + "test": "shx rm -rf ./.out && tsc && mocha --opts spec/support/default.opts '.out/spec/**/*-spec.js'", + "test:cover": "nyc mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts 'spec/**/*-spec.ts'", "tests2png": "npm run build_spec && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js", "watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15" }, @@ -196,7 +206,7 @@ "mocha-in-sauce": "0.0.1", "npm-run-all": "^4.0.2", "npm-scripts-info": "^0.3.4", - "nyc": "^10.2.0", + "nyc": "^11.3.0", "opn-cli": "^3.1.0", "platform": "^1.3.1", "promise": "^7.1.1", @@ -210,6 +220,7 @@ "sinon": "^2.1.0", "sinon-chai": "^2.9.0", "source-map-support": "^0.4.0", + "ts-node": "^3.3.0", "tslib": "^1.5.0", "tslint": "^4.4.2", "typescript": "~2.0.6", diff --git a/spec/support/coverage.opts b/spec/support/coverage.opts new file mode 100644 index 0000000000..36ce4f121b --- /dev/null +++ b/spec/support/coverage.opts @@ -0,0 +1,9 @@ +--require spec/helpers/testScheduler-ui.ts +--ui spec/helpers/testScheduler-ui.ts + +--reporter dot + +--globals WebSocket,FormData,XDomainRequest,ActiveXObject + +--recursive +--timeout 5000 From 8d137ac0a401533f48512b703abc62f3f82ab81f Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 25 Oct 2017 12:15:44 -0700 Subject: [PATCH 11/77] chore(package): integrate test script --- .travis.yml | 2 +- appveyor.yml | 4 ++-- package.json | 15 +++++++-------- spec/support/coverage.opts | 2 +- spec/support/default.opts | 2 -- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d8485997c..8c81800286 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,5 +33,5 @@ script: - npm test after_success: - - if [ "$FULL_VALIDATE" == "true" ]; then npm run test:cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi + - if [ "$FULL_VALIDATE" == "true" ]; then npm run test:cover && npx nyc report --reporter=text-lcov | npx coveralls; fi - if [ "$FULL_VALIDATE" == "true" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ -n "$SAUCE_ACCESS_KEY" ]; then npm run build_spec_browser && grunt --gruntfile spec/support/mocha.sauce.gruntfile.js; fi \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index bcfe9682e5..0cf80ca9ca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,9 +13,9 @@ install: - npm install build_script: - - npm run build_spec + - npm run build_all test_script: - - npm run cover + - npm test version: "{build}" \ No newline at end of file diff --git a/package.json b/package.json index 07b12ba50a..25b5f8c737 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ ], "exclude": [ "node_modules", + "dist", "typings", "*.d.ts", "src/**/MiscJSDoc.ts" @@ -26,7 +27,6 @@ "ts-node/register" ], "reporter": [ - "json", "html" ], "all": true @@ -52,7 +52,6 @@ "build_perf": "Build CJS & Global build, run macro performance test", "build_test": "Build CJS package & test spec, execute mocha test runner", "build_docs": "Build ESM2015 & global package, create documentation using it", - "build_spec": "Build test specs", "check_circular_dependencies": "Check codebase has circular dependencies", "clean_dist_cjs": "Clean up existing CJS package output", "clean_dist_esm5": "Clean up existing ESM/ES5 package output", @@ -89,8 +88,7 @@ "build_global": "npm-run-all clean_dist_global build_esm5_for_rollup && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core clean_dist_esm5_for_rollup", "build_umd": "npm-run-all clean_dist_global && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core", "build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf", - "build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs build_spec tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015", - "build_spec": "tsc --project ./spec --pretty", + "build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015", "build_spec_browser": "webpack --config spec/support/webpack.mocha.config.js", "check_circular_dependencies": "madge ./dist/cjs --circular", "clean_dist": "shx rm -rf ./dist", @@ -105,7 +103,7 @@ "compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", "compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", "compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers", - "copy_sources": "mkdir -p dist && rsync -a ./src/ ./dist/src", + "copy_sources": "mkdirp dist && shx cp -r ./src/ ./dist/src", "decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..", "doctoc": "doctoc CONTRIBUTING.md", "generate_packages": "node .make-packages.js", @@ -118,9 +116,9 @@ "prepublish": "shx rm -rf ./typings && typings install && npm run build_all", "publish_docs": "./publish_docs.sh", "test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html", - "test": "shx rm -rf ./.out && tsc && mocha --opts spec/support/default.opts '.out/spec/**/*-spec.js'", - "test:cover": "nyc mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts 'spec/**/*-spec.ts'", - "tests2png": "npm run build_spec && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js", + "test": "cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts \"spec/**/*-spec.ts\"", + "test:cover": "cross-env TS_NODE_FAST=true nyc npm test", + "tests2png": "tsc && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js", "watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15" }, "repository": { @@ -181,6 +179,7 @@ "colors": "1.1.2", "commitizen": "^2.8.6", "coveralls": "^2.11.13", + "cross-env": "^5.1.0", "cz-conventional-changelog": "^1.2.0", "danger": "^1.1.0", "doctoc": "^1.0.0", diff --git a/spec/support/coverage.opts b/spec/support/coverage.opts index 36ce4f121b..dd16ba8048 100644 --- a/spec/support/coverage.opts +++ b/spec/support/coverage.opts @@ -6,4 +6,4 @@ --globals WebSocket,FormData,XDomainRequest,ActiveXObject --recursive ---timeout 5000 +--timeout 5000 \ No newline at end of file diff --git a/spec/support/default.opts b/spec/support/default.opts index 419ffe734d..10a6277758 100644 --- a/spec/support/default.opts +++ b/spec/support/default.opts @@ -1,10 +1,8 @@ ---require source-map-support/register --require .out/spec/helpers/testScheduler-ui.js --ui .out/spec/helpers/testScheduler-ui.js --reporter dot ---full-trace --check-leaks --globals WebSocket,FormData,XDomainRequest,ActiveXObject From 1bd0a58e173b00abb269a5f674933a55c384b60f Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 30 Oct 2017 08:15:36 -0700 Subject: [PATCH 12/77] fix(IteratorObservable): get new iterator for each subscription (#2497) BREAKING CHANGE: IteratorObservable no longer share iterator between subscription - closes #2496 --- spec/observables/IteratorObservable-spec.ts | 18 ++++++++++++++++++ src/observable/IteratorObservable.ts | 14 ++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/spec/observables/IteratorObservable-spec.ts b/spec/observables/IteratorObservable-spec.ts index 7907a27b80..9ed503297f 100644 --- a/spec/observables/IteratorObservable-spec.ts +++ b/spec/observables/IteratorObservable-spec.ts @@ -47,6 +47,24 @@ describe('IteratorObservable', () => { ); }); + it('should get new iterator for each subscription', () => { + const expected = [ + Rx.Notification.createNext(10), + Rx.Notification.createNext(20), + Rx.Notification.createComplete() + ]; + + const e1 = IteratorObservable.create(new Int32Array([10, 20])).observeOn(rxTestScheduler); + + let v1, v2: Array>; + e1.materialize().toArray().subscribe((x) => v1 = x); + e1.materialize().toArray().subscribe((x) => v2 = x); + + rxTestScheduler.flush(); + expect(v1).to.deep.equal(expected); + expect(v2).to.deep.equal(expected); + }); + it('should finalize generators if the subscription ends', () => { const iterator = { finalized: false, diff --git a/src/observable/IteratorObservable.ts b/src/observable/IteratorObservable.ts index 5bc3f8897c..bf1cee7bfd 100644 --- a/src/observable/IteratorObservable.ts +++ b/src/observable/IteratorObservable.ts @@ -11,8 +11,6 @@ import { Subscriber } from '../Subscriber'; * @hide true */ export class IteratorObservable extends Observable { - private iterator: any; - static create(iterator: any, scheduler?: IScheduler): IteratorObservable { return new IteratorObservable(iterator, scheduler); } @@ -45,20 +43,20 @@ export class IteratorObservable extends Observable { ( this).schedule(state); } - constructor(iterator: any, private scheduler?: IScheduler) { + constructor(private readonly iteratorObject: any, private scheduler?: IScheduler) { super(); - if (iterator == null) { + if (iteratorObject == null) { throw new Error('iterator cannot be null.'); + } else if (!iteratorObject[Symbol_iterator]) { + throw new TypeError('object is not iterable'); } - - this.iterator = getIterator(iterator); } protected _subscribe(subscriber: Subscriber): TeardownLogic { - let index = 0; - const { iterator, scheduler } = this; + const { scheduler } = this; + const iterator = getIterator(this.iteratorObject); if (scheduler) { return scheduler.schedule(IteratorObservable.dispatch, 0, { From abf1627cbd8e444f9e35ef3e4abd9cec34df7fba Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 30 Oct 2017 16:24:08 +0100 Subject: [PATCH 13/77] Removing tests that don't make any sense (#3013) * test(partition): remove nonsense test Test wasn't testing anything, it was passing the partition function itself to the expect(), which doesn't really do anything of value. * test(repeat): remove nonsense tests These tests were really testing the rethrowing capability of Observable, as triggered when the scheduler was flushed. The call directly above the flush to `repeat` does nothing but create a new observable that is never subscribed to --- spec/operators/partition-spec.ts | 5 ---- spec/operators/repeat-spec.ts | 48 -------------------------------- 2 files changed, 53 deletions(-) diff --git a/spec/operators/partition-spec.ts b/spec/operators/partition-spec.ts index 000e4c36fa..606c6a79bd 100644 --- a/spec/operators/partition-spec.ts +++ b/spec/operators/partition-spec.ts @@ -255,11 +255,6 @@ describe('Observable.prototype.partition', () => { expectSubscriptions(e1.subscriptions).toBe([e1subs, e1subs]); }); - it('should throw without predicate', () => { - const e1 = hot('--a-b---a------d----'); - expect(e1.partition).to.throw(); - }); - it('should accept thisArg', () => { const thisArg = {}; diff --git a/spec/operators/repeat-spec.ts b/spec/operators/repeat-spec.ts index a4dcd95d7d..aacc5d3e33 100644 --- a/spec/operators/repeat-spec.ts +++ b/spec/operators/repeat-spec.ts @@ -216,54 +216,6 @@ describe('Observable.prototype.repeat', () => { expectSubscriptions(e1.subscriptions).toBe(e1subs); }); - it('should terminate repeat and throw if source subscription to _next throws', () => { - const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => { throw new Error('error'); }); - - expect(() => { - e1.repeat(3); - rxTestScheduler.flush(); - }).to.throw(); - }); - - it('should terminate repeat and throw if source subscription to _complete throws', () => { - const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => { - //noop - }, () => { - //noop - }, () => { throw new Error('error'); }); - - expect(() => { - e1.repeat(3); - rxTestScheduler.flush(); - }).to.throw(); - }); - - it('should terminate repeat and throw if source subscription to _next throws when repeating infinitely', () => { - const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => { throw new Error('error'); }); - - expect(() => { - e1.repeat(); - rxTestScheduler.flush(); - }).to.throw(); - }); - - it('should terminate repeat and throw if source subscription to _complete throws when repeating infinitely', () => { - const e1 = Observable.of(1, 2, rxTestScheduler); - e1.subscribe(() => { - //noop - }, () => { - //noop - }, () => { throw new Error('error'); }); - - expect(() => { - e1.repeat(); - rxTestScheduler.flush(); - }).to.throw(); - }); - it('should raise error after first emit succeed', () => { let repeated = false; From 2f395da56189090215462bb88cfd2014c842be57 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 30 Oct 2017 08:26:50 -0700 Subject: [PATCH 14/77] chore(TypeScript): Bump up typescript to latest (#3009) * chore(package): bump up typescript to latest * chore(typings): remove deprecated typings * chore(spec): remove redundant reference * fix(error): custom error inherits via setPrototypeof BREAKING CHANGE: IE10 and lower will need to polyfill `Object.setPrototypeOf` --- .dependency-cruiser.json | 107 ++++++++++++++++++++++++++ .travis.yml | 2 +- package.json | 16 ++-- spec/helpers/marble-testing.ts | 1 - spec/helpers/test-helper.ts | 2 - spec/helpers/testScheduler-ui.ts | 2 - spec/util/UnsubscriptionError-spec.ts | 4 +- src/observable/dom/AjaxObservable.ts | 4 + src/util/ArgumentOutOfRangeError.ts | 7 +- src/util/EmptyError.ts | 7 +- src/util/ObjectUnsubscribedError.ts | 7 +- src/util/TimeoutError.ts | 7 +- src/util/UnsubscriptionError.ts | 8 +- typings.json | 12 --- 14 files changed, 138 insertions(+), 48 deletions(-) create mode 100644 .dependency-cruiser.json delete mode 100644 typings.json diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json new file mode 100644 index 0000000000..56d0cf216a --- /dev/null +++ b/.dependency-cruiser.json @@ -0,0 +1,107 @@ +{ + "forbidden": [ + { + "name": "not-to-spec", + "comment": "Don't allow dependencies from outside the spec folder to spec", + "severity": "error", + "from": { + "pathNot": "^spec" + }, + "to": { + "path": "^spec" + } + }, + { + "name": "not-to-spec", + "comment": "Don't allow dependencies to (typescript/ javascript/ coffeescript) spec files", + "severity": "error", + "from": {}, + "to": { + "path": "\\.spec\\.[js|ts|ls|coffee|litcoffee|coffee\\.md]$" + } + }, + { + "name": "no-deprecated-core", + "comment": "Warn about dependencies on deprecated core modules.", + "severity": "warn", + "from": {}, + "to": { + "dependencyTypes": [ + "core" + ], + "path": "^(punycode|domain)$" + } + }, + { + "name": "no-deprecated-npm", + "comment": "These npm modules are deprecated - find an alternative.", + "severity": "warn", + "from": {}, + "to": { + "dependencyTypes": [ + "deprecated" + ] + } + }, + { + "name": "not-to-dev-dep", + "severity": "error", + "comment": "Don't allow dependencies from src/app/lib to a development only package", + "from": { + "path": "^(src|app|lib)" + }, + "to": { + "dependencyTypes": [ + "npm-dev" + ] + } + }, + { + "name": "no-non-package-json", + "severity": "error", + "comment": "Don't allow dependencies to packages not in package.json (except from within node_modules)", + "from": { + "pathNot": "^node_modules" + }, + "to": { + "dependencyTypes": [ + "undetermined", + "npm-no-pkg", + "npm-unknown" + ], + "pathNot": "^electron" + } + }, + { + "name": "peer-deps-used", + "comment": "Error about the use of a peer dependency (peer dependencies are deprecated).", + "severity": "error", + "from": {}, + "to": { + "dependencyTypes": [ + "npm-peer" + ] + } + }, + { + "name": "no-duplicate-dep-types", + "comment": "Warn if a dependency occurs in your package.json more than once (technically: has more than one dependency type)", + "severity": "warn", + "from": {}, + "to": { + "moreThanOneDependencyType": true + } + }, + { + "name": "no-circular", + "severity": "error", + "comment": "Error in case we have circular dependencies", + "from": { + "path": "^src" + }, + "to": { + "circular": true + } + } + ] +} diff --git a/.travis.yml b/.travis.yml index 8c81800286..0302f70603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: install: - npm install - - if [ "$FULL_VALIDATE" == "true" ]; then npm run lint && npm run check_circular_dependencies; fi + - if [ "$FULL_VALIDATE" == "true" ]; then npm run lint && npm run test:circular; fi script: - if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then echo {} > ./.babelrc && npx danger; fi diff --git a/package.json b/package.json index 25b5f8c737..c0280dce15 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "exclude": [ "node_modules", "dist", - "typings", "*.d.ts", "src/**/MiscJSDoc.ts" ], @@ -52,7 +51,6 @@ "build_perf": "Build CJS & Global build, run macro performance test", "build_test": "Build CJS package & test spec, execute mocha test runner", "build_docs": "Build ESM2015 & global package, create documentation using it", - "check_circular_dependencies": "Check codebase has circular dependencies", "clean_dist_cjs": "Clean up existing CJS package output", "clean_dist_esm5": "Clean up existing ESM/ES5 package output", "clean_dist_esm2015": "Clean up existing ESM/ES2015 package output", @@ -90,7 +88,6 @@ "build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf", "build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015", "build_spec_browser": "webpack --config spec/support/webpack.mocha.config.js", - "check_circular_dependencies": "madge ./dist/cjs --circular", "clean_dist": "shx rm -rf ./dist", "clean_dist_cjs": "shx rm -rf ./dist/cjs", "clean_dist_esm5": "shx rm -rf ./dist/esm5", @@ -113,11 +110,12 @@ "lint": "npm-run-all --parallel lint_*", "perf": "protractor protractor.conf.js", "perf_micro": "node ./perf/micro/index.js", - "prepublish": "shx rm -rf ./typings && typings install && npm run build_all", + "prepublish": "shx rm -rf ./typings && npm run build_all", "publish_docs": "./publish_docs.sh", "test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html", "test": "cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts \"spec/**/*-spec.ts\"", "test:cover": "cross-env TS_NODE_FAST=true nyc npm test", + "test:circular": "dependency-cruise --validate .dependency-cruiser.json -x \"^node_modules\" src", "tests2png": "tsc && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js", "watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15" }, @@ -171,6 +169,12 @@ "homepage": "https://github.com/ReactiveX/RxJS", "devDependencies": { "@angular-devkit/build-optimizer": "0.0.24", + "@types/chai": "^4.0.4", + "@types/lodash": "^4.14.80", + "@types/mocha": "^2.2.44", + "@types/node": "^8.0.47", + "@types/sinon": "^2.3.7", + "@types/sinon-chai": "^2.7.29", "babel-polyfill": "^6.23.0", "benchmark": "^2.1.0", "benchpress": "2.0.0-beta.1", @@ -182,6 +186,7 @@ "cross-env": "^5.1.0", "cz-conventional-changelog": "^1.2.0", "danger": "^1.1.0", + "dependency-cruiser": "^2.6.0", "doctoc": "^1.0.0", "escape-string-regexp": "^1.0.5 ", "esdoc": "^0.4.7", @@ -222,8 +227,7 @@ "ts-node": "^3.3.0", "tslib": "^1.5.0", "tslint": "^4.4.2", - "typescript": "~2.0.6", - "typings": "^2.0.0", + "typescript": "latest", "validate-commit-msg": "^2.14.0", "watch": "^1.0.1", "webpack": "^1.13.1", diff --git a/spec/helpers/marble-testing.ts b/spec/helpers/marble-testing.ts index 1589bb2941..56007993d6 100644 --- a/spec/helpers/marble-testing.ts +++ b/spec/helpers/marble-testing.ts @@ -1,4 +1,3 @@ -/// import { Observable } from '../../src/Observable'; import { SubscriptionLog } from '../../src/testing/SubscriptionLog'; import { ColdObservable } from '../../src/testing/ColdObservable'; diff --git a/spec/helpers/test-helper.ts b/spec/helpers/test-helper.ts index 24a8626348..753756a181 100644 --- a/spec/helpers/test-helper.ts +++ b/spec/helpers/test-helper.ts @@ -1,4 +1,3 @@ -/// declare const global: any; import * as Rx from '../../src/Rx'; @@ -6,7 +5,6 @@ import { ObservableInput } from '../../src/Observable'; import { root } from '../../src/util/root'; import { $$iterator } from '../../src/symbol/iterator'; import $$symbolObservable from 'symbol-observable'; -import { Observable } from '../../src/Observable'; export function lowerCaseO(...args: Array): Rx.Observable { diff --git a/spec/helpers/testScheduler-ui.ts b/spec/helpers/testScheduler-ui.ts index 5d0c2d455c..5f24505ef6 100644 --- a/spec/helpers/testScheduler-ui.ts +++ b/spec/helpers/testScheduler-ui.ts @@ -1,5 +1,3 @@ -/// - import * as _ from 'lodash'; //import * as commonInterface from 'mocha/lib/interfaces/common'; //import * as escapeRe from 'escape-string-regexp'; diff --git a/spec/util/UnsubscriptionError-spec.ts b/spec/util/UnsubscriptionError-spec.ts index dad0143705..f2f1db9b27 100644 --- a/spec/util/UnsubscriptionError-spec.ts +++ b/spec/util/UnsubscriptionError-spec.ts @@ -19,9 +19,7 @@ describe('UnsubscriptionError', () => { subscription.unsubscribe(); } catch (err) { expect(err instanceof UnsubscriptionError).to.equal(true); - expect(err.message).to.equal(`2 errors occurred during unsubscription: - 1) ${err1} - 2) ${err2}`); + expect(err.errors).to.deep.equal([err1, err2]); expect(err.name).to.equal('UnsubscriptionError'); } }); diff --git a/src/observable/dom/AjaxObservable.ts b/src/observable/dom/AjaxObservable.ts index b8fc058a7c..427d1f1eee 100644 --- a/src/observable/dom/AjaxObservable.ts +++ b/src/observable/dom/AjaxObservable.ts @@ -452,6 +452,9 @@ export class AjaxError extends Error { this.status = xhr.status; this.responseType = xhr.responseType || request.responseType; this.response = parseXhrResponse(this.responseType, xhr); + + this.name = 'AjaxError'; + (Object as any).setPrototypeOf(this, AjaxError.prototype); } } @@ -480,5 +483,6 @@ function parseXhrResponse(responseType: string, xhr: XMLHttpRequest) { export class AjaxTimeoutError extends AjaxError { constructor(xhr: XMLHttpRequest, request: AjaxRequest) { super('ajax timeout', xhr, request); + (Object as any).setPrototypeOf(this, AjaxTimeoutError.prototype); } } diff --git a/src/util/ArgumentOutOfRangeError.ts b/src/util/ArgumentOutOfRangeError.ts index 4384a2b465..d3155f3361 100644 --- a/src/util/ArgumentOutOfRangeError.ts +++ b/src/util/ArgumentOutOfRangeError.ts @@ -10,9 +10,8 @@ */ export class ArgumentOutOfRangeError extends Error { constructor() { - const err: any = super('argument out of range'); - ( this).name = err.name = 'ArgumentOutOfRangeError'; - ( this).stack = err.stack; - ( this).message = err.message; + super('argument out of range'); + this.name = 'ArgumentOutOfRangeError'; + (Object as any).setPrototypeOf(this, ArgumentOutOfRangeError.prototype); } } diff --git a/src/util/EmptyError.ts b/src/util/EmptyError.ts index d1184ab189..fbfe7bf88d 100644 --- a/src/util/EmptyError.ts +++ b/src/util/EmptyError.ts @@ -10,9 +10,8 @@ */ export class EmptyError extends Error { constructor() { - const err: any = super('no elements in sequence'); - ( this).name = err.name = 'EmptyError'; - ( this).stack = err.stack; - ( this).message = err.message; + super('no elements in sequence'); + this.name = 'EmptyError'; + (Object as any).setPrototypeOf(this, EmptyError.prototype); } } diff --git a/src/util/ObjectUnsubscribedError.ts b/src/util/ObjectUnsubscribedError.ts index 460a31029a..fb005457e7 100644 --- a/src/util/ObjectUnsubscribedError.ts +++ b/src/util/ObjectUnsubscribedError.ts @@ -9,9 +9,8 @@ */ export class ObjectUnsubscribedError extends Error { constructor() { - const err: any = super('object unsubscribed'); - ( this).name = err.name = 'ObjectUnsubscribedError'; - ( this).stack = err.stack; - ( this).message = err.message; + super('object unsubscribed'); + this.name = 'ObjectUnsubscribedError'; + (Object as any).setPrototypeOf(this, ObjectUnsubscribedError.prototype); } } diff --git a/src/util/TimeoutError.ts b/src/util/TimeoutError.ts index c68adffac4..506249e94d 100644 --- a/src/util/TimeoutError.ts +++ b/src/util/TimeoutError.ts @@ -7,9 +7,8 @@ */ export class TimeoutError extends Error { constructor() { - const err: any = super('Timeout has occurred'); - ( this).name = err.name = 'TimeoutError'; - ( this).stack = err.stack; - ( this).message = err.message; + super('Timeout has occurred'); + + (Object as any).setPrototypeOf(this, TimeoutError.prototype); } } diff --git a/src/util/UnsubscriptionError.ts b/src/util/UnsubscriptionError.ts index 412164ed76..47999fc1e0 100644 --- a/src/util/UnsubscriptionError.ts +++ b/src/util/UnsubscriptionError.ts @@ -4,12 +4,10 @@ */ export class UnsubscriptionError extends Error { constructor(public errors: any[]) { - super(); - const err: any = Error.call(this, errors ? + super(errors ? `${errors.length} errors occurred during unsubscription: ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : ''); - ( this).name = err.name = 'UnsubscriptionError'; - ( this).stack = err.stack; - ( this).message = err.message; + this.name = 'UnsubscriptionError'; + (Object as any).setPrototypeOf(this, UnsubscriptionError.prototype); } } diff --git a/typings.json b/typings.json deleted file mode 100644 index e329d616d7..0000000000 --- a/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "devDependencies": { - "chai": "registry:npm/chai#3.5.0+20160723033700", - "lodash": "registry:npm/lodash#4.0.0+20161015015725", - "sinon": "registry:npm/sinon#1.16.0+20160723033700", - "sinon-chai": "registry:npm/sinon-chai#2.8.0+20160310030142" - }, - "globalDevDependencies": { - "mocha": "registry:env/mocha#2.2.5+20160926180742", - "node": "registry:env/node#6.0.0+20161105011511" - } -} From 01d1575b5514dedfabc8520a977210e3af717e93 Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Mon, 30 Oct 2017 14:26:40 -0400 Subject: [PATCH 15/77] fix(TSC): Fixing TSC errors. Fixes #3020 --- spec/helpers/test-helper.ts | 42 +++++++++++++++++++------------------ tsconfig.json | 5 +++-- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/spec/helpers/test-helper.ts b/spec/helpers/test-helper.ts index 753756a181..8c910871b1 100644 --- a/spec/helpers/test-helper.ts +++ b/spec/helpers/test-helper.ts @@ -24,25 +24,27 @@ export function lowerCaseO(...args: Array): Rx.Observable { return o; }; -export const createObservableInputs = (value: T) => Rx.Observable.of>( - Rx.Observable.of(value), - Rx.Observable.of(value, Rx.Scheduler.async), - [value], - Promise.resolve(value), - ({ - [$$iterator]: () => { - const iteratorResults = [ - { value, done: false }, - { done: true } - ]; - return { - next: () => { - return iteratorResults.shift(); - } - }; - } - }), - ({ [$$symbolObservable]: () => Rx.Observable.of(value) }) -); +export function createObservableInputs(value: T): Rx.Observable> { + return Rx.Observable.of>( + Rx.Observable.of(value), + Rx.Observable.of(value, Rx.Scheduler.async), + [value], + Promise.resolve(value), + ({ + [$$iterator]: () => { + const iteratorResults = [ + { value, done: false }, + { done: true } + ]; + return { + next: () => { + return iteratorResults.shift(); + } + }; + } + }), + ({ [$$symbolObservable]: () => Rx.Observable.of(value) }) + ); +} global.__root__ = root; diff --git a/tsconfig.json b/tsconfig.json index 82af808607..56d2fd0385 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,10 +16,11 @@ "es2015.collection", "es2015.promise", "dom" - ] + ], + "types": ["mocha", "node"] }, "formatCodeOptions": { "indentSize": 2, "tabSize": 2 } -} \ No newline at end of file +} From b41fefc24483c58c89e7523fdbff8f14e3235423 Mon Sep 17 00:00:00 2001 From: Jason Aden Date: Mon, 30 Oct 2017 15:42:29 -0700 Subject: [PATCH 16/77] build: fix pointer to Rx.d.ts file Fixes #3005 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0280dce15..c3067ccd3e 100644 --- a/package.json +++ b/package.json @@ -236,7 +236,7 @@ "engines": { "npm": ">=2.0.0" }, - "typings": "./dist/package/typings/Rx.d.ts", + "typings": "./dist/package/Rx.d.ts", "dependencies": { "symbol-observable": "^1.0.1" } From 3b66a0bddf0e4a6bc8320e9a1c8e70be676a20a4 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 30 Oct 2017 20:37:05 -0700 Subject: [PATCH 17/77] build(tsconfig): introduce extended tsconfig for target (#3019) --- package.json | 8 ++++---- tsconfig.json | 4 ++-- tsconfig/tsconfig.base.json | 7 +++++++ tsconfig/tsconfig.cjs.json | 10 ++++++++++ tsconfig/tsconfig.esm2015.json | 8 ++++++++ tsconfig/tsconfig.esm5.json | 8 ++++++++ tsconfig/tsconfig.esm5.rollup.json | 7 +++++++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 tsconfig/tsconfig.base.json create mode 100644 tsconfig/tsconfig.cjs.json create mode 100644 tsconfig/tsconfig.esm2015.json create mode 100644 tsconfig/tsconfig.esm5.json create mode 100644 tsconfig/tsconfig.esm5.rollup.json diff --git a/package.json b/package.json index c0280dce15..8f9ab02e3b 100644 --- a/package.json +++ b/package.json @@ -95,11 +95,11 @@ "clean_dist_esm2015": "shx rm -rf ./dist/esm2015", "clean_dist_global": "shx rm -rf ./dist/global", "commit": "git-cz", - "compile_dist_cjs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/cjs --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node -d --declarationDir ./dist/typings", - "compile_dist_esm5": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5 --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", - "compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", + "compile_dist_cjs": "tsc -p ./tsconfig/tsconfig.cjs.json", + "compile_dist_esm5": "tsc -p ./tsconfig/tsconfig.esm5.json", + "compile_dist_esm2015": "tsc -p ./tsconfig/tsconfig.esm2015.json", "compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node", - "compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers", + "compile_dist_esm5_for_rollup": "tsc -p ./tsconfig/tsconfig.esm5.rollup.json", "copy_sources": "mkdirp dist && shx cp -r ./src/ ./dist/src", "decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..", "doctoc": "doctoc CONTRIBUTING.md", diff --git a/tsconfig.json b/tsconfig.json index 82af808607..6d6702f311 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,9 @@ "removeComments": false, "preserveConstEnums": true, "sourceMap": true, - "declaration": true, - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitReturns": true, + "noImplicitThis": true, "suppressImplicitAnyIndexErrors": true, "moduleResolution": "node", "target": "es5", diff --git a/tsconfig/tsconfig.base.json b/tsconfig/tsconfig.base.json new file mode 100644 index 0000000000..a7d3c0211e --- /dev/null +++ b/tsconfig/tsconfig.base.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "files": [ + "../dist/src/Rx.ts", + "../dist/src/add/observable/of.ts" + ] +} \ No newline at end of file diff --git a/tsconfig/tsconfig.cjs.json b/tsconfig/tsconfig.cjs.json new file mode 100644 index 0000000000..853c8caae3 --- /dev/null +++ b/tsconfig/tsconfig.cjs.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "declaration": true, + "declarationDir": "../dist/typings", + "outDir": "../dist/cjs" + } +} \ No newline at end of file diff --git a/tsconfig/tsconfig.esm2015.json b/tsconfig/tsconfig.esm2015.json new file mode 100644 index 0000000000..8af3692089 --- /dev/null +++ b/tsconfig/tsconfig.esm2015.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "es2015", + "target": "es2015", + "outDir": "../dist/esm2015" + } +} \ No newline at end of file diff --git a/tsconfig/tsconfig.esm5.json b/tsconfig/tsconfig.esm5.json new file mode 100644 index 0000000000..9ab8769a95 --- /dev/null +++ b/tsconfig/tsconfig.esm5.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "es2015", + "target": "es5", + "outDir": "../dist/esm5" + } +} \ No newline at end of file diff --git a/tsconfig/tsconfig.esm5.rollup.json b/tsconfig/tsconfig.esm5.rollup.json new file mode 100644 index 0000000000..cbe7bfe90c --- /dev/null +++ b/tsconfig/tsconfig.esm5.rollup.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.esm5.json", + "compilerOptions": { + "outDir": "../dist/esm5_for_rollup", + "noEmitHelpers": true + } +} \ No newline at end of file From 27a7df90dc053ac2840b919e10d4a26d720f3989 Mon Sep 17 00:00:00 2001 From: Martin Sikora Date: Thu, 2 Nov 2017 07:46:08 +0100 Subject: [PATCH 18/77] docs(takeUntil): update docs to match operator's behavior 2160 --- doc/decision-tree-widget/tree.yml | 2 +- src/operator/takeUntil.ts | 5 +++-- src/operators/takeUntil.ts | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/decision-tree-widget/tree.yml b/doc/decision-tree-widget/tree.yml index db63f316be..b648ae6e73 100644 --- a/doc/decision-tree-widget/tree.yml +++ b/doc/decision-tree-widget/tree.yml @@ -43,7 +43,7 @@ children: - label: based on a given amount children: - label: takeLast - - label: until another Observable emits a value or completes + - label: until another Observable emits a value children: - label: takeUntil - label: I want to ignore values diff --git a/src/operator/takeUntil.ts b/src/operator/takeUntil.ts index 75b0c10899..66cdf22258 100644 --- a/src/operator/takeUntil.ts +++ b/src/operator/takeUntil.ts @@ -6,14 +6,15 @@ import { takeUntil as higherOrder } from '../operators/takeUntil'; * Observable emits a value. * * Lets values pass until a second Observable, - * `notifier`, emits something. Then, it completes. + * `notifier`, emits a value. Then, it completes. * * * * `takeUntil` subscribes and begins mirroring the source Observable. It also * monitors a second Observable, `notifier` that you provide. If the `notifier` * emits a value, the output Observable stops mirroring the source Observable - * and completes. + * and completes. If the `notifier` doesn't emit any value and completes + * then `takeUntil` will pass all values. * * @example Tick every second until the first click happens * var interval = Rx.Observable.interval(1000); diff --git a/src/operators/takeUntil.ts b/src/operators/takeUntil.ts index ca89686ee4..ac49558a8c 100644 --- a/src/operators/takeUntil.ts +++ b/src/operators/takeUntil.ts @@ -14,14 +14,15 @@ import { MonoTypeOperatorFunction } from '../interfaces'; * Observable emits a value. * * Lets values pass until a second Observable, - * `notifier`, emits something. Then, it completes. + * `notifier`, emits a value. Then, it completes. * * * * `takeUntil` subscribes and begins mirroring the source Observable. It also * monitors a second Observable, `notifier` that you provide. If the `notifier` - * emits a value or a complete notification, the output Observable stops - * mirroring the source Observable and completes. + * emits a value, the output Observable stops mirroring the source Observable + * and completes. If the `notifier` doesn't emit any value and completes + * then `takeUntil` will pass all values. * * @example Tick every second until the first click happens * var interval = Rx.Observable.interval(1000); From 0f3cf716154967ee0f3de555e40ffaac3fd64949 Mon Sep 17 00:00:00 2001 From: Jason Aden Date: Thu, 2 Nov 2017 22:17:33 -0400 Subject: [PATCH 19/77] fix(SystemJS): avoid node module resolution of pipeable operators (#3025) Fixes #2971, #2996, #3011 --- .make-packages.js | 33 +++++-------- src/operators.ts | 108 +++++++++++++++++++++++++++++++++++++++++ src/operators/index.ts | 108 ----------------------------------------- 3 files changed, 120 insertions(+), 129 deletions(-) create mode 100644 src/operators.ts delete mode 100644 src/operators/index.ts diff --git a/.make-packages.js b/.make-packages.js index 983b075ff7..8a0adac635 100644 --- a/.make-packages.js +++ b/.make-packages.js @@ -30,9 +30,6 @@ const ESM2015_PKG = PKG_ROOT + '_esm2015/'; const UMD_PKG = PKG_ROOT + 'bundles/'; const TYPE_PKG = PKG_ROOT; -const EXPORT_FILE = 'index.js'; - - // License info for minified files let licenseUrl = 'https://github.com/ReactiveX/RxJS/blob/master/LICENSE.txt'; let license = 'Apache License 2.0 ' + licenseUrl; @@ -46,7 +43,13 @@ let rootPackageJson = Object.assign({}, pkg, { typings: './Rx.d.ts' }); -// Get a list of the file names +// Get a list of the file names. Sort in reverse order so re-export files +// such as "operators.js" are AFTER their more specfic exports, such as +// "operators/map.js". This is due to a Webpack bug for node-resolved imports +// (rxjs/operators resolves to rxjs/operators.js), Webpack's "alias" +// functionality requires that the most broad mapping (rxjs/operators) be at +// the end of the alias mapping object. Created Webpack issue: +// https://github.com/webpack/webpack/issues/5870 const fileNames = klawSync(CJS_ROOT, { nodir: true, filter: function(item) { @@ -54,12 +57,15 @@ const fileNames = klawSync(CJS_ROOT, { } }) .map(item => item.path) -.map(path => path.slice((`${__dirname}/${CJS_ROOT}`).length)); +.map(path => path.slice((`${__dirname}/${CJS_ROOT}`).length)) +.sort().reverse(); // Execute build optimizer transforms on ESM5 files fileNames.map(fileName => { if (!bo) return fileName; let fullPath = path.resolve(__dirname, ESM5_ROOT, fileName); + // The file won't exist when running build_test as we don't create the ESM5 sources + if (!fs.existsSync(fullPath)) return fileName; let content = fs.readFileSync(fullPath).toString(); let transformed = bo.transformJavascript({ content: content, @@ -70,7 +76,7 @@ fileNames.map(fileName => { }); // Create an object hash mapping imports to file names -const fileMappings = fileNames.reduce((acc, fileName) => { +const importTargets = fileNames.reduce((acc, fileName) => { // Get the name of the file to be the new directory const directory = fileName.slice(0, fileName.length - 3); @@ -78,21 +84,6 @@ const fileMappings = fileNames.reduce((acc, fileName) => { return acc; }, {}); -// For node-resolved imports (rxjs/operators resolves to rxjs/operators/index.js), Webpack's "alias" -// functionality requires that the most broad mapping (rxjs/operators) be at the end of the alias -// mapping object. Created Webpack issue: https://github.com/webpack/webpack/issues/5870 -const importTargets = Object.assign({}, fileMappings, fileNames.reduce((acc, fileName) => { - // If the fileName is index.js (re-export file), create another entry - // for the root of the export. Example: - // fileName = 'rxjs/operators/index.js' - // create entry: - // {'rxjs/operators': 'rxjs/operators/index.js'} - if (fileName.slice(fileName.length - EXPORT_FILE.length) === EXPORT_FILE) { - acc[fileName.slice(0, EXPORT_FILE.length + 1)] = fileName; - } - return acc; -}, {})); - createImportTargets(importTargets, "_esm5/", ESM5_PKG); createImportTargets(importTargets, "_esm2015/", ESM2015_PKG); diff --git a/src/operators.ts b/src/operators.ts new file mode 100644 index 0000000000..798e525000 --- /dev/null +++ b/src/operators.ts @@ -0,0 +1,108 @@ +export { audit } from './operators/audit'; +export { auditTime } from './operators/auditTime'; +export { buffer } from './operators/buffer'; +export { bufferCount } from './operators/bufferCount'; +export { bufferTime } from './operators/bufferTime'; +export { bufferToggle } from './operators/bufferToggle'; +export { bufferWhen } from './operators/bufferWhen'; +export { catchError } from './operators/catchError'; +export { combineAll } from './operators/combineAll'; +export { combineLatest } from './operators/combineLatest'; +export { concat } from './operators/concat'; +export { concatAll } from './operators/concatAll'; +export { concatMap } from './operators/concatMap'; +export { concatMapTo } from './operators/concatMapTo'; +export { count } from './operators/count'; +export { debounce } from './operators/debounce'; +export { debounceTime } from './operators/debounceTime'; +export { defaultIfEmpty } from './operators/defaultIfEmpty'; +export { delay } from './operators/delay'; +export { delayWhen } from './operators/delayWhen'; +export { dematerialize } from './operators/dematerialize'; +export { distinct } from './operators/distinct'; +export { distinctUntilChanged } from './operators/distinctUntilChanged'; +export { distinctUntilKeyChanged } from './operators/distinctUntilKeyChanged'; +export { elementAt } from './operators/elementAt'; +export { every } from './operators/every'; +export { exhaust } from './operators/exhaust'; +export { exhaustMap } from './operators/exhaustMap'; +export { expand } from './operators/expand'; +export { filter } from './operators/filter'; +export { finalize } from './operators/finalize'; +export { find } from './operators/find'; +export { findIndex } from './operators/findIndex'; +export { first } from './operators/first'; +export { groupBy } from './operators/groupBy'; +export { ignoreElements } from './operators/ignoreElements'; +export { isEmpty } from './operators/isEmpty'; +export { last } from './operators/last'; +export { map } from './operators/map'; +export { mapTo } from './operators/mapTo'; +export { materialize } from './operators/materialize'; +export { max } from './operators/max'; +export { merge } from './operators/merge'; +export { mergeAll } from './operators/mergeAll'; +export { mergeMap } from './operators/mergeMap'; +export { mergeMap as flatMap } from './operators/mergeMap'; +export { mergeMapTo } from './operators/mergeMapTo'; +export { mergeScan } from './operators/mergeScan'; +export { min } from './operators/min'; +export { multicast } from './operators/multicast'; +export { observeOn } from './operators/observeOn'; +export { onErrorResumeNext } from './operators/onErrorResumeNext'; +export { pairwise } from './operators/pairwise'; +export { partition } from './operators/partition'; +export { pluck } from './operators/pluck'; +export { publish } from './operators/publish'; +export { publishBehavior } from './operators/publishBehavior'; +export { publishLast } from './operators/publishLast'; +export { publishReplay } from './operators/publishReplay'; +export { race } from './operators/race'; +export { reduce } from './operators/reduce'; +export { repeat } from './operators/repeat'; +export { repeatWhen } from './operators/repeatWhen'; +export { retry } from './operators/retry'; +export { retryWhen } from './operators/retryWhen'; +export { refCount } from './operators/refCount'; +export { sample } from './operators/sample'; +export { sampleTime } from './operators/sampleTime'; +export { scan } from './operators/scan'; +export { sequenceEqual } from './operators/sequenceEqual'; +export { share } from './operators/share'; +export { shareReplay } from './operators/shareReplay'; +export { single } from './operators/single'; +export { skip } from './operators/skip'; +export { skipLast } from './operators/skipLast'; +export { skipUntil } from './operators/skipUntil'; +export { skipWhile } from './operators/skipWhile'; +export { startWith } from './operators/startWith'; +/** + * TODO(https://github.com/ReactiveX/rxjs/issues/2900): Add back subscribeOn once it can be + * treeshaken. Currently if this export is added back, it + * forces apps to bring in asap scheduler along with + * Immediate, root, and other supporting code. + */ +// export { subscribeOn } from './operators/subscribeOn'; +export { switchAll } from './operators/switchAll'; +export { switchMap } from './operators/switchMap'; +export { switchMapTo } from './operators/switchMapTo'; +export { take } from './operators/take'; +export { takeLast } from './operators/takeLast'; +export { takeUntil } from './operators/takeUntil'; +export { takeWhile } from './operators/takeWhile'; +export { tap } from './operators/tap'; +export { throttle } from './operators/throttle'; +export { throttleTime } from './operators/throttleTime'; +export { timeInterval } from './operators/timeInterval'; +export { timeout } from './operators/timeout'; +export { timeoutWith } from './operators/timeoutWith'; +export { timestamp } from './operators/timestamp'; +export { toArray } from './operators/toArray'; +export { window } from './operators/window'; +export { windowCount } from './operators/windowCount'; +export { windowTime } from './operators/windowTime'; +export { windowToggle } from './operators/windowToggle'; +export { windowWhen } from './operators/windowWhen'; +export { withLatestFrom } from './operators/withLatestFrom'; +export { zip } from './operators/zip'; +export { zipAll } from './operators/zipAll'; diff --git a/src/operators/index.ts b/src/operators/index.ts deleted file mode 100644 index 1d4ef82e4c..0000000000 --- a/src/operators/index.ts +++ /dev/null @@ -1,108 +0,0 @@ -export { audit } from './audit'; -export { auditTime } from './auditTime'; -export { buffer } from './buffer'; -export { bufferCount } from './bufferCount'; -export { bufferTime } from './bufferTime'; -export { bufferToggle } from './bufferToggle'; -export { bufferWhen } from './bufferWhen'; -export { catchError } from './catchError'; -export { combineAll } from './combineAll'; -export { combineLatest } from './combineLatest'; -export { concat } from './concat'; -export { concatAll } from './concatAll'; -export { concatMap } from './concatMap'; -export { concatMapTo } from './concatMapTo'; -export { count } from './count'; -export { debounce } from './debounce'; -export { debounceTime } from './debounceTime'; -export { defaultIfEmpty } from './defaultIfEmpty'; -export { delay } from './delay'; -export { delayWhen } from './delayWhen'; -export { dematerialize } from './dematerialize'; -export { distinct } from './distinct'; -export { distinctUntilChanged } from './distinctUntilChanged'; -export { distinctUntilKeyChanged } from './distinctUntilKeyChanged'; -export { elementAt } from './elementAt'; -export { every } from './every'; -export { exhaust } from './exhaust'; -export { exhaustMap } from './exhaustMap'; -export { expand } from './expand'; -export { filter } from './filter'; -export { finalize } from './finalize'; -export { find } from './find'; -export { findIndex } from './findIndex'; -export { first } from './first'; -export { groupBy } from './groupBy'; -export { ignoreElements } from './ignoreElements'; -export { isEmpty } from './isEmpty'; -export { last } from './last'; -export { map } from './map'; -export { mapTo } from './mapTo'; -export { materialize } from './materialize'; -export { max } from './max'; -export { merge } from './merge'; -export { mergeAll } from './mergeAll'; -export { mergeMap } from './mergeMap'; -export { mergeMap as flatMap } from './mergeMap'; -export { mergeMapTo } from './mergeMapTo'; -export { mergeScan } from './mergeScan'; -export { min } from './min'; -export { multicast } from './multicast'; -export { observeOn } from './observeOn'; -export { onErrorResumeNext } from './onErrorResumeNext'; -export { pairwise } from './pairwise'; -export { partition } from './partition'; -export { pluck } from './pluck'; -export { publish } from './publish'; -export { publishBehavior } from './publishBehavior'; -export { publishLast } from './publishLast'; -export { publishReplay } from './publishReplay'; -export { race } from './race'; -export { reduce } from './reduce'; -export { repeat } from './repeat'; -export { repeatWhen } from './repeatWhen'; -export { retry } from './retry'; -export { retryWhen } from './retryWhen'; -export { refCount } from './refCount'; -export { sample } from './sample'; -export { sampleTime } from './sampleTime'; -export { scan } from './scan'; -export { sequenceEqual } from './sequenceEqual'; -export { share } from './share'; -export { shareReplay } from './shareReplay'; -export { single } from './single'; -export { skip } from './skip'; -export { skipLast } from './skipLast'; -export { skipUntil } from './skipUntil'; -export { skipWhile } from './skipWhile'; -export { startWith } from './startWith'; -/** - * TODO(https://github.com/ReactiveX/rxjs/issues/2900): Add back subscribeOn once it can be - * treeshaken. Currently if this export is added back, it - * forces apps to bring in asap scheduler along with - * Immediate, root, and other supporting code. - */ -// export { subscribeOn } from './subscribeOn'; -export { switchAll } from './switchAll'; -export { switchMap } from './switchMap'; -export { switchMapTo } from './switchMapTo'; -export { take } from './take'; -export { takeLast } from './takeLast'; -export { takeUntil } from './takeUntil'; -export { takeWhile } from './takeWhile'; -export { tap } from './tap'; -export { throttle } from './throttle'; -export { throttleTime } from './throttleTime'; -export { timeInterval } from './timeInterval'; -export { timeout } from './timeout'; -export { timeoutWith } from './timeoutWith'; -export { timestamp } from './timestamp'; -export { toArray } from './toArray'; -export { window } from './window'; -export { windowCount } from './windowCount'; -export { windowTime } from './windowTime'; -export { windowToggle } from './windowToggle'; -export { windowWhen } from './windowWhen'; -export { withLatestFrom } from './withLatestFrom'; -export { zip } from './zip'; -export { zipAll } from './zipAll'; From 74b5b1a943bd9fe307b12ec36f4ce71ab2c9998a Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Thu, 2 Nov 2017 19:56:25 -0700 Subject: [PATCH 20/77] refactor(groupBy): Remove Map polyfill - Removes Map polyfill - Removes FastMap impl - Tests in latest Chrome and Node show no discernable difference in performance between Map and Object has a hashtable for our use case. - Adds an error that is thrown immediately at runtime if Map does not exist. BREAKING CHANGE: Older runtimes will require Map to be polyfilled to use `groupBy` --- spec/util/FastMap-spec.ts | 81 ----------------------------------- spec/util/MapPolyfill-spec.ts | 78 --------------------------------- src/operators/groupBy.ts | 9 ++-- src/util/FastMap.ts | 30 ------------- src/util/Map.ts | 4 -- src/util/MapPolyfill.ts | 43 ------------------- 6 files changed, 6 insertions(+), 239 deletions(-) delete mode 100644 spec/util/FastMap-spec.ts delete mode 100644 spec/util/MapPolyfill-spec.ts delete mode 100644 src/util/FastMap.ts delete mode 100644 src/util/Map.ts delete mode 100644 src/util/MapPolyfill.ts diff --git a/spec/util/FastMap-spec.ts b/spec/util/FastMap-spec.ts deleted file mode 100644 index a9b8c520c6..0000000000 --- a/spec/util/FastMap-spec.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { expect } from 'chai'; -import { FastMap } from '../../src/util/FastMap'; - -/** @test {FastMap} */ -describe('FastMap', () => { - it('should exist', () => { - expect(FastMap).to.be.a('function'); - }); - - it('should accept string as keys', () => { - const map = new FastMap(); - const key1 = 'keyOne'; - const key2 = 'keyTwo'; - - map.set(key1, 'yo'); - map.set(key2, 'what up'); - - expect(map.get(key1)).to.equal('yo'); - expect(map.get(key2)).to.equal('what up'); - }); - - it('should allow setting keys twice', () => { - const map = new FastMap(); - const key1 = 'keyOne'; - - map.set(key1, 'sing'); - map.set(key1, 'yodel'); - - expect(map.get(key1)).to.equal('yodel'); - }); - - it('should have a delete method that removes keys', () => { - const map = new FastMap(); - const key1 = 'keyOne'; - - map.set(key1, 'sing'); - - expect(map.delete(key1)).to.be.true; - expect(map.get(key1)).to.be.a('null'); - }); - - it('should clear all', () => { - const map = new FastMap(); - const key1 = 'keyOne'; - const key2 = 'keyTwo'; - - map.set(key1, 'yo'); - map.set(key2, 'what up'); - - map.clear(); - - expect(map.get(key1)).to.be.a('undefined'); - expect(map.get(key2)).to.be.a('undefined'); - }); - - describe('prototype.forEach', () => { - it('should exist', () => { - const map = new FastMap(); - expect(map.forEach).to.be.a('function'); - }); - - it('should iterate over keys and values', () => { - const expectedKeys = ['a', 'b', 'c']; - const expectedValues = [1, 2, 3]; - const map = new FastMap(); - map.set('a', 1); - map.set('b', 2); - map.set('c', 3); - const thisArg = {}; - - map.forEach(function (value, key) { - expect(this).to.equal(thisArg); - expect(value).to.equal(expectedValues.shift()); - expect(key).to.equal(expectedKeys.shift()); - }, thisArg); - - expect(expectedValues.length).to.equal(0); - expect(expectedKeys.length).to.equal(0); - }); - }); -}); diff --git a/spec/util/MapPolyfill-spec.ts b/spec/util/MapPolyfill-spec.ts deleted file mode 100644 index 2fcc33fffd..0000000000 --- a/spec/util/MapPolyfill-spec.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { expect } from 'chai'; -import { MapPolyfill } from '../../src/util/MapPolyfill'; - -/** @test {MapPolyfill} */ -describe('MapPolyfill', () => { - it('should exist', () => { - expect(MapPolyfill).to.be.a('function'); - }); - - it('should act like a hashtable that accepts objects as keys', () => { - const map = new MapPolyfill(); - const key1 = {}; - const key2 = {}; - - map.set('test', 'hi'); - map.set(key1, 'yo'); - map.set(key2, 'what up'); - - expect(map.get('test')).to.equal('hi'); - expect(map.get(key1)).to.equal('yo'); - expect(map.get(key2)).to.equal('what up'); - expect(map.size).to.equal(3); - }); - - it('should allow setting keys twice', () => { - const map = new MapPolyfill(); - const key1 = {}; - - map.set(key1, 'sing'); - map.set(key1, 'yodel'); - - expect(map.get(key1)).to.equal('yodel'); - expect(map.size).to.equal(1); - }); - - it('should have a delete method that removes keys', () => { - const map = new MapPolyfill(); - const key1 = {}; - - map.set(key1, 'sing'); - expect(map.size).to.equal(1); - - map.delete(key1); - - expect(map.size).to.equal(0); - expect(map.get(key1)).to.be.a('undefined'); - }); - - describe('prototype.forEach', () => { - it('should exist', () => { - const map = new MapPolyfill(); - expect(map.forEach).to.be.a('function'); - }); - - it('should iterate over keys and values', () => { - const expectedKeys = ['a', 'b', 'c']; - const expectedValues = [1, 2, 3]; - const map = new MapPolyfill(); - map.set('a', 1); - map.set('b', 2); - map.set('c', 3); - - const thisArg = { - arg: 'value' - }; - - //intentionally not using lambda to avoid typescript's this context capture - map.forEach(function (value, key) { - expect(this).to.equal(thisArg); - expect(value).to.equal(expectedValues.shift()); - expect(key).to.equal(expectedKeys.shift()); - }, thisArg); - - expect(expectedValues.length).to.equal(0); - expect(expectedKeys.length).to.equal(0); - }); - }); -}); diff --git a/src/operators/groupBy.ts b/src/operators/groupBy.ts index 3ed28a6966..f94e941fea 100644 --- a/src/operators/groupBy.ts +++ b/src/operators/groupBy.ts @@ -3,10 +3,13 @@ import { Subscription } from '../Subscription'; import { Observable } from '../Observable'; import { Operator } from '../Operator'; import { Subject } from '../Subject'; -import { Map } from '../util/Map'; -import { FastMap } from '../util/FastMap'; import { OperatorFunction } from '../interfaces'; +/** Assert that map is present for this operator */ +if (!Map) { + throw new Error('Map not found, please polyfill'); +} + /* tslint:disable:max-line-length */ export function groupBy(keySelector: (value: T) => K): OperatorFunction>; export function groupBy(keySelector: (value: T) => K, elementSelector: void, durationSelector: (grouped: GroupedObservable) => Observable): OperatorFunction>; @@ -144,7 +147,7 @@ class GroupBySubscriber extends Subscriber implements RefCountSubscr let groups = this.groups; if (!groups) { - groups = this.groups = typeof key === 'string' ? new FastMap() : new Map(); + groups = this.groups = new Map>(); } let group = groups.get(key); diff --git a/src/util/FastMap.ts b/src/util/FastMap.ts deleted file mode 100644 index c7bd54a1b7..0000000000 --- a/src/util/FastMap.ts +++ /dev/null @@ -1,30 +0,0 @@ -export class FastMap { - private values: Object = {}; - - delete(key: string): boolean { - this.values[key] = null; - return true; - } - - set(key: string, value: any): FastMap { - this.values[key] = value; - return this; - } - - get(key: string): any { - return this.values[key]; - } - - forEach(cb: (value: any, key: any) => void, thisArg?: any): void { - const values = this.values; - for (let key in values) { - if (values.hasOwnProperty(key) && values[key] !== null) { - cb.call(thisArg, values[key], key); - } - } - } - - clear(): void { - this.values = {}; - } -} \ No newline at end of file diff --git a/src/util/Map.ts b/src/util/Map.ts deleted file mode 100644 index 563017c000..0000000000 --- a/src/util/Map.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { root } from './root'; -import { MapPolyfill } from './MapPolyfill'; - -export const Map = root.Map || (() => MapPolyfill)(); \ No newline at end of file diff --git a/src/util/MapPolyfill.ts b/src/util/MapPolyfill.ts deleted file mode 100644 index 7100f4b191..0000000000 --- a/src/util/MapPolyfill.ts +++ /dev/null @@ -1,43 +0,0 @@ -export class MapPolyfill { - public size = 0; - private _values: any[] = []; - private _keys: any[] = []; - - get(key: any) { - const i = this._keys.indexOf(key); - return i === -1 ? undefined : this._values[i]; - } - - set(key: any, value: any) { - const i = this._keys.indexOf(key); - if (i === -1) { - this._keys.push(key); - this._values.push(value); - this.size++; - } else { - this._values[i] = value; - } - return this; - } - - delete(key: any): boolean { - const i = this._keys.indexOf(key); - if (i === -1) { return false; } - this._values.splice(i, 1); - this._keys.splice(i, 1); - this.size--; - return true; - } - - clear(): void { - this._keys.length = 0; - this._values.length = 0; - this.size = 0; - } - - forEach(cb: Function, thisArg: any): void { - for (let i = 0; i < this.size; i++) { - cb.call(thisArg, this._values[i], this._keys[i]); - } - } -} \ No newline at end of file From 5eb6af7d90f9359a7e32fbd80230ef362b01189d Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Thu, 2 Nov 2017 20:41:25 -0700 Subject: [PATCH 21/77] refactor(asap): Remove setImmediate polyfill Gets rid of fancy polyfill and uses Promise to schedule instead, since Promise is required for several key parts of the library to work. Also setImmediate does not appear to be getting standardized. BREAKING CHANGE: Old runtimes must polyfill Promise in order to use ASAP scheduling. --- spec/util/Immediate-spec.ts | 728 ++---------------------------------- src/util/Immediate.ts | 249 +----------- 2 files changed, 48 insertions(+), 929 deletions(-) diff --git a/spec/util/Immediate-spec.ts b/spec/util/Immediate-spec.ts index 8c8eaea432..e95200fd04 100644 --- a/spec/util/Immediate-spec.ts +++ b/spec/util/Immediate-spec.ts @@ -1,703 +1,33 @@ import { expect } from 'chai'; -import * as sinon from 'sinon'; -import { ImmediateDefinition } from '../../src/util/Immediate'; -import * as Rx from '../../src/Rx'; - -declare const __root__: any; - -/** @test {ImmediateDefinition} */ -describe('ImmediateDefinition', () => { - let sandbox; - beforeEach(function () { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function () { - sandbox.restore(); - }); - - it('should have setImmediate and clearImmediate methods', () => { - const result = new ImmediateDefinition(__root__); - expect(result.setImmediate).to.be.a('function'); - expect(result.clearImmediate).to.be.a('function'); - }); - - describe('when setImmediate exists on root', () => { - it('should use the setImmediate and clearImmediate methods from root', () => { - let setImmediateCalled = false; - let clearImmediateCalled = false; - - const root = { - setImmediate: () => { - setImmediateCalled = true; - }, - clearImmediate: () => { - clearImmediateCalled = true; - } - }; - - const result = new ImmediateDefinition(root); - - result.setImmediate(() => { - //noop - }); - result.clearImmediate(null); - - expect(setImmediateCalled).to.be.ok; - expect(clearImmediateCalled).to.be.ok; - }); - }); - - describe('prototype.createProcessNextTickSetImmediate()', () => { - it('should create the proper flavor of setImmediate using process.nextTick', () => { - const instance = { - root: { - process: { - nextTick: sinon.spy() - } - }, - runIfPresent: () => { - //noop - }, - partiallyApplied: sinon.spy(), - addFromSetImmediateArguments: sinon.stub().returns(123456) - }; - - const setImmediateImpl = ImmediateDefinition.prototype.createProcessNextTickSetImmediate.call(instance); - - expect(setImmediateImpl).to.be.a('function'); - - const action = () => { - //noop - }; - const handle = setImmediateImpl(action); - - expect(handle).to.equal(123456); - expect(instance.addFromSetImmediateArguments).have.been.called; - expect(instance.partiallyApplied).have.been.calledWith(instance.runIfPresent, handle); - }); - }); - - describe('prototype.createPostMessageSetImmediate()', () => { - it('should create the proper flavor of setImmediate using postMessage', () => { - let addEventListenerCalledWith = null; - - const instance = { - root: { - addEventListener: (name: any, callback: any) => { - addEventListenerCalledWith = [name, callback]; - }, - postMessage: sinon.spy(), - Math: { - random: sinon.stub().returns(42) - } - }, - runIfPresent: sinon.spy(), - addFromSetImmediateArguments: sinon.stub().returns(123456) - }; - - const setImmediateImpl = ImmediateDefinition.prototype.createPostMessageSetImmediate.call(instance); - - expect(setImmediateImpl).to.be.a('function'); - expect(addEventListenerCalledWith[0]).to.equal('message'); - - addEventListenerCalledWith[1]({ data: 'setImmediate$42$123456', source: instance.root }); - - expect(instance.runIfPresent).have.been.calledWith(123456); - - const action = () => { - //noop - }; - const handle = setImmediateImpl(action); - - expect(handle).to.equal(123456); - expect(instance.addFromSetImmediateArguments).have.been.called; - expect(instance.root.postMessage).have.been.calledWith('setImmediate$42$123456', '*'); - }); - }); - - describe('prototype.createMessageChannelSetImmediate', () => { - it('should create the proper flavor of setImmediate that uses message channels', () => { - const port1 = {}; - const port2 = { - postMessage: sinon.spy() - }; - - function MockMessageChannel() { - this.port1 = port1; - this.port2 = port2; - } - - const instance = { - root: { - MessageChannel: MockMessageChannel - }, - runIfPresent: sinon.spy(), - addFromSetImmediateArguments: sinon.stub().returns(123456) - }; - - const setImmediateImpl = ImmediateDefinition.prototype.createMessageChannelSetImmediate.call(instance); - - expect(setImmediateImpl).to.be.a('function'); - expect((port1).onmessage).to.be.a('function'); - - (port1).onmessage({ data: 'something' }); - - expect(instance.runIfPresent).have.been.calledWith('something'); - - const action = () => { - //noop - }; - const handle = setImmediateImpl(action); - - expect(handle).to.equal(123456); - expect(port2.postMessage).have.been.calledWith(123456); - }); - }); - - describe('prototype.createReadyStateChangeSetImmediate', () => { - it('should create the proper flavor of setImmediate that uses readystatechange on a DOM element', () => { - const fakeScriptElement = {}; - - const instance = { - root: { - document: { - createElement: sinon.stub().returns(fakeScriptElement), - documentElement: { - appendChild: sinon.spy(), - removeChild: sinon.spy(), - } - } - }, - runIfPresent: sinon.spy(), - addFromSetImmediateArguments: sinon.stub().returns(123456) - }; - - const setImmediateImpl = ImmediateDefinition.prototype.createReadyStateChangeSetImmediate.call(instance); - - expect(setImmediateImpl).to.be.a('function'); - - const action = () => { - //noop - }; - const handle = setImmediateImpl(action); - - expect(handle).to.equal(123456); - expect(instance.root.document.createElement).have.been.calledWith('script'); - expect((fakeScriptElement).onreadystatechange).to.be.a('function'); - expect(instance.root.document.documentElement.appendChild).have.been.calledWith(fakeScriptElement); - - (fakeScriptElement).onreadystatechange(); - - expect(instance.runIfPresent).have.been.calledWith(handle); - expect((fakeScriptElement).onreadystatechange).to.be.a('null'); - expect(instance.root.document.documentElement.removeChild).have.been.calledWith(fakeScriptElement); - }); - }); - - describe('when setImmediate does *not* exist on root', () => { - describe('when it can use process.nextTick', () => { - it('should use the post message impl', () => { - const nextTickImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(true); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'createProcessNextTickSetImmediate').returns(nextTickImpl); - - const result = new ImmediateDefinition({}); - expect(ImmediateDefinition.prototype.canUseProcessNextTick).have.been.called; - expect(ImmediateDefinition.prototype.canUsePostMessage).not.have.been.called; - expect(ImmediateDefinition.prototype.canUseMessageChannel).not.have.been.called; - expect(ImmediateDefinition.prototype.canUseReadyStateChange).not.have.been.called; - expect(ImmediateDefinition.prototype.createProcessNextTickSetImmediate).have.been.called; - expect(result.setImmediate).to.equal(nextTickImpl); - }); - }); - - describe('when it cannot use process.nextTick', () => { - it('should use the post message impl', () => { - const postMessageImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(true); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'createPostMessageSetImmediate').returns(postMessageImpl); - - const result = new ImmediateDefinition({}); - expect(ImmediateDefinition.prototype.canUseProcessNextTick).have.been.called; - expect(ImmediateDefinition.prototype.canUsePostMessage).have.been.called; - expect(ImmediateDefinition.prototype.canUseMessageChannel).not.have.been.called; - expect(ImmediateDefinition.prototype.canUseReadyStateChange).not.have.been.called; - expect(ImmediateDefinition.prototype.createPostMessageSetImmediate).have.been.called; - expect(result.setImmediate).to.equal(postMessageImpl); - }); - }); - - describe('when it cannot use process.nextTick or postMessage', () => { - it('should use the readystatechange impl', () => { - const messageChannelImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(true); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'createMessageChannelSetImmediate').returns(messageChannelImpl); - - const result = new ImmediateDefinition({}); - expect(ImmediateDefinition.prototype.canUseProcessNextTick).have.been.called; - expect(ImmediateDefinition.prototype.canUsePostMessage).have.been.called; - expect(ImmediateDefinition.prototype.canUseMessageChannel).have.been.called; - expect(ImmediateDefinition.prototype.canUseReadyStateChange).not.have.been.called; - expect(ImmediateDefinition.prototype.createMessageChannelSetImmediate).have.been.called; - expect(result.setImmediate).to.equal(messageChannelImpl); - }); - }); - - describe('when it cannot use process.nextTick, postMessage or Message channels', () => { - it('should use the readystatechange impl', () => { - const readyStateChangeImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(true); - sandbox.stub(ImmediateDefinition.prototype, 'createReadyStateChangeSetImmediate').returns(readyStateChangeImpl); - - const result = new ImmediateDefinition({}); - expect(ImmediateDefinition.prototype.canUseProcessNextTick).have.been.called; - expect(ImmediateDefinition.prototype.canUsePostMessage).have.been.called; - expect(ImmediateDefinition.prototype.canUseMessageChannel).have.been.called; - expect(ImmediateDefinition.prototype.canUseReadyStateChange).have.been.called; - expect(ImmediateDefinition.prototype.createReadyStateChangeSetImmediate).have.been.called; - expect(result.setImmediate).to.equal(readyStateChangeImpl); - }); - }); - - describe('when no other methods to implement setImmediate are available', () => { - it('should use the setTimeout impl', () => { - const setTimeoutImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'createSetTimeoutSetImmediate').returns(setTimeoutImpl); - - const result = new ImmediateDefinition({}); - expect(ImmediateDefinition.prototype.canUseProcessNextTick).have.been.called; - expect(ImmediateDefinition.prototype.canUsePostMessage).have.been.called; - expect(ImmediateDefinition.prototype.canUseMessageChannel).have.been.called; - expect(ImmediateDefinition.prototype.canUseReadyStateChange).have.been.called; - expect(ImmediateDefinition.prototype.createSetTimeoutSetImmediate).have.been.called; - expect(result.setImmediate).to.equal(setTimeoutImpl); - }); - }); - }); - - describe('partiallyApplied', () => { - describe('when passed a function as the first argument', () => { - it('should return a function that takes no arguments and will be called with the passed arguments', () => { - const fn = sinon.spy(); - const result = ImmediateDefinition.prototype.partiallyApplied(fn, 'arg1', 'arg2', 'arg3'); - - expect(result).to.be.a('function'); - expect(fn).not.have.been.called; - - result(); - - expect(fn).have.been.calledWith('arg1', 'arg2', 'arg3'); - }); - }); - - describe('when passed a non-function as an argument', () => { - it('should coerce to a string and convert to a function which will be called by the returned function', () => { - __root__.__wasCalled = null; - const fnStr = '__wasCalled = true;'; - const result = ImmediateDefinition.prototype.partiallyApplied(fnStr); - - expect(result).to.be.a('function'); - - result(); - - expect(__root__.__wasCalled).to.be.true; - - delete __root__.__wasCalled; - }); - }); - }); - - describe('prototype.identify', () => { - it('should use Object.toString to return an identifier string', () => { - function MockObject() { - //noop - } - sandbox.stub(MockObject.prototype, 'toString').returns('[object HEYO!]'); - - const instance = { - root: { - Object: MockObject - } - }; - - const result = (ImmediateDefinition).prototype.identify.call(instance); - - expect(result).to.equal('[object HEYO!]'); - }); - }); - - describe('prototype.canUseProcessNextTick', () => { - describe('when root.process does not identify as [object process]', () => { - it('should return false', () => { - const instance = { - root: { - process: {} - }, - identify: sinon.stub().returns('[object it-is-not-a-tumor]') - }; - - const result = ImmediateDefinition.prototype.canUseProcessNextTick.call(instance); - - expect(result).to.be.false; - expect(instance.identify).have.been.calledWith(instance.root.process); - }); - }); - - describe('when root.process identifies as [object process]', () => { - it('should return true', () => { - const instance = { - root: { - process: {} - }, - identify: sinon.stub().returns('[object process]') - }; - - const result = ImmediateDefinition.prototype.canUseProcessNextTick.call(instance); - - expect(result).to.be.true; - expect(instance.identify).have.been.calledWith(instance.root.process); - }); - }); - }); - - describe('prototype.canUsePostMessage', () => { - describe('when there is a global postMessage function', () => { - describe('and importScripts does NOT exist', () => { - it('should maintain any existing onmessage handler', () => { - const originalOnMessage = () => { - //noop - }; - const instance = { - root: { - onmessage: originalOnMessage - } - }; - - ImmediateDefinition.prototype.canUsePostMessage.call(instance); - expect(instance.root.onmessage).to.equal(originalOnMessage); - }); - - describe('and postMessage is synchronous', () => { - it('should return false', () => { - let postMessageCalled = false; - const instance = { - root: { - postMessage: function () { - postMessageCalled = true; - this.onmessage(); - } - } - }; - - const result = ImmediateDefinition.prototype.canUsePostMessage.call(instance); - expect(result).to.be.false; - expect(postMessageCalled).to.be.true; - }); - }); - - describe('and postMessage is asynchronous', () => { - it('should return true', () => { - let postMessageCalled = false; - const instance = { - root: { - postMessage: function () { - postMessageCalled = true; - const _onmessage = this.onmessage; - setTimeout(() => { _onmessage(); }); - } - } - }; - - const result = ImmediateDefinition.prototype.canUsePostMessage.call(instance); - expect(result).to.be.true; - expect(postMessageCalled).to.be.true; - }); - }); - }); - - describe('and importScripts *does* exist because it is a worker', () => { - it('should return false', () => { - const instance = { - root: { - postMessage: function () { - //noop - }, - importScripts: function () { - //noop - } - } - }; - - const result = ImmediateDefinition.prototype.canUsePostMessage.call(instance); - expect(result).to.be.false; - }); - }); - }); - - describe('when there is NOT a global postMessage function', () => { - it('should return false', () => { - const instance = { - root: {} - }; - - const result = ImmediateDefinition.prototype.canUsePostMessage.call(instance); - - expect(result).to.be.false; - }); - }); - }); - - describe('prototype.canUseMessageChannel', () => { - it('should return true if MessageChannel exists', () => { - const instance = { - root: { - MessageChannel: function () { - //noop - } - } - }; - - const result = ImmediateDefinition.prototype.canUseMessageChannel.call(instance); - - expect(result).to.be.true; - }); - - it('should return false if MessageChannel does NOT exist', () => { - const instance = { - root: {} - }; - - const result = ImmediateDefinition.prototype.canUseMessageChannel.call(instance); - - expect(result).to.be.false; - }); - }); - - describe('prototype.canUseReadyStateChange', () => { - describe('when there is a document in global scope', () => { - it('should return true if created script elements have an onreadystatechange property', () => { - const fakeScriptElement = { - onreadystatechange: null - }; - - const instance = { - root: { - document: { - createElement: sinon.stub().returns(fakeScriptElement) - } - } - }; - - const result = ImmediateDefinition.prototype.canUseReadyStateChange.call(instance); - - expect(result).to.be.true; - expect(instance.root.document.createElement).have.been.calledWith('script'); - }); - - it('should return false if created script elements do NOT have an onreadystatechange property', () => { - const fakeScriptElement = {}; - - const instance = { - root: { - document: { - createElement: sinon.stub().returns(fakeScriptElement) - } - } - }; - - const result = ImmediateDefinition.prototype.canUseReadyStateChange.call(instance); - - expect(result).to.be.false; - expect(instance.root.document.createElement).have.been.calledWith('script'); - }); - }); - - it('should return false if there is no document in global scope', () => { - const instance = { - root: {} - }; - - const result = ImmediateDefinition.prototype.canUseReadyStateChange.call(instance); - - expect(result).to.be.false; - }); - }); - - describe('prototype.addFromSetImmediateArguments', () => { - it('should add to tasksByHandle and increment the nextHandle', () => { - const partiallyAppliedResult = {}; - - const instance = { - tasksByHandle: {}, - nextHandle: 42, - partiallyApplied: sinon.stub().returns(partiallyAppliedResult) - }; - - const args = [() => { - //noop - }, 'foo', 'bar']; - - const handle = ImmediateDefinition.prototype.addFromSetImmediateArguments.call(instance, args); - - expect(handle).to.equal(42); - expect(instance.nextHandle).to.equal(43); - expect(instance.tasksByHandle[42]).to.equal(partiallyAppliedResult); - }); - }); - - describe('clearImmediate', () => { - it('should delete values from tasksByHandle', () => { - const setTimeoutImpl = () => { - //noop - }; - sandbox.stub(ImmediateDefinition.prototype, 'canUseProcessNextTick').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUsePostMessage').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseMessageChannel').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'canUseReadyStateChange').returns(false); - sandbox.stub(ImmediateDefinition.prototype, 'createSetTimeoutSetImmediate').returns(setTimeoutImpl); - - const Immediate = new ImmediateDefinition({}); - Immediate.tasksByHandle[123456] = () => { - //noop - }; - - expect('123456' in Immediate.tasksByHandle).to.be.true; - - Immediate.clearImmediate(123456); - - expect('123456' in Immediate.tasksByHandle).to.be.false; - }); - }); - - describe('prototype.runIfPresent', () => { - it('should delay running the task if it is currently running a task', () => { - const mockApplied = () => { - //noop - }; - - const instance = { - root: { - setTimeout: sinon.spy(), - Object: Object - }, - currentlyRunningATask: true, - partiallyApplied: sinon.stub().returns(mockApplied) - }; - - ImmediateDefinition.prototype.runIfPresent.call(instance, 123456); - - expect(instance.partiallyApplied).have.been.calledWith((instance).runIfPresent, 123456); - expect(instance.root.setTimeout).have.been.calledWith(mockApplied, 0); - }); - - it('should not error if there is no task currently running and the handle passed is not found', () => { - expect(() => { - const instance = { - root: { - setTimeout: sinon.spy(), - Object: Object - }, - currentlyRunningATask: false, - tasksByHandle: {} - }; - - ImmediateDefinition.prototype.runIfPresent.call(instance, 888888); - }).not.to.throw(); - }); - - describe('when a task is found for the handle', () => { - it('should execute the task and clean up after', () => { - const instance = { - root: { - setTimeout: sinon.spy(), - Object: Object - }, - currentlyRunningATask: false, - tasksByHandle: {}, - clearImmediate: sinon.spy() - }; - - const spy = sinon.stub(); - - spy({ - task: function () { - expect(instance.currentlyRunningATask).to.be.true; - } - }); - instance.tasksByHandle[123456] = spy; - - ImmediateDefinition.prototype.runIfPresent.call(instance, 123456); - expect(instance.clearImmediate).have.been.calledWith(123456); - }); - }); - }); - - describe('prototype.createSetTimeoutSetImmediate', () => { - it('should create a proper setImmediate implementation that uses setTimeout', () => { - const mockApplied = () => { - //noop - }; - - const instance = { - root: { - setTimeout: sinon.spy() - }, - addFromSetImmediateArguments: sinon.stub().returns(123456), - runIfPresent: function () { - //noop - }, - partiallyApplied: sinon.stub().returns(mockApplied) - }; - - const setImmediateImpl = ImmediateDefinition.prototype.createSetTimeoutSetImmediate.call(instance); - - const handle = setImmediateImpl(); - - expect(handle).to.equal(123456); - expect(instance.addFromSetImmediateArguments).have.been.called; - expect(instance.root.setTimeout).have.been.calledWith(mockApplied, 0); - }); - }); - - describe('integration test', () => { - it('should work', (done: MochaDone) => { - const results = []; - Rx.Observable.from([1, 2, 3], Rx.Scheduler.asap) - .subscribe((x: number) => { - results.push(x); - }, () => { - done(new Error('should not be called')); - }, () => { - expect(results).to.deep.equal([1, 2, 3]); - done(); - }); +import { Immediate } from '../../src/util/Immediate'; + +describe('Immediate', () => { + it('should schedule on the next microtask', (done) => { + const results: number[] = []; + results.push(1); + setTimeout(() => results.push(5)); + Immediate.setImmediate(() => results.push(3)); + results.push(2); + Promise.resolve().then(() => results.push(4)); + + setTimeout(() => { + expect(results).to.deep.equal([1, 2, 3, 4, 5]); + done(); + }); + }); + + it('should cancel the task with clearImmediate', (done) => { + const results: number[] = []; + results.push(1); + setTimeout(() => results.push(5)); + const handle = Immediate.setImmediate(() => results.push(3)); + Immediate.clearImmediate(handle); + results.push(2); + Promise.resolve().then(() => results.push(4)); + + setTimeout(() => { + expect(results).to.deep.equal([1, 2, 4, 5]); + done(); }); }); }); diff --git a/src/util/Immediate.ts b/src/util/Immediate.ts index 918a41e298..b285b29ec5 100644 --- a/src/util/Immediate.ts +++ b/src/util/Immediate.ts @@ -2,237 +2,26 @@ Some credit for this helper goes to http://github.com/YuzuJS/setImmediate */ -import { root } from './root'; +let nextHandle = 0; -export class ImmediateDefinition { - setImmediate: (cb: () => void) => number; +const tasksByHandle: { [handle: string]: () => void } = {}; - clearImmediate: (handle: number) => void; - - private identify(o: any): string { - return this.root.Object.prototype.toString.call(o); - } - - tasksByHandle: any; - - nextHandle: number; - - currentlyRunningATask: boolean; - - constructor(private root: any) { - if (root.setImmediate && typeof root.setImmediate === 'function') { - this.setImmediate = root.setImmediate.bind(root); - this.clearImmediate = root.clearImmediate.bind(root); - } else { - this.nextHandle = 1; - this.tasksByHandle = {}; - this.currentlyRunningATask = false; - - // Don't get fooled by e.g. browserify environments. - if (this.canUseProcessNextTick()) { - // For Node.js before 0.9 - this.setImmediate = this.createProcessNextTickSetImmediate(); - } else if (this.canUsePostMessage()) { - // For non-IE10 modern browsers - this.setImmediate = this.createPostMessageSetImmediate(); - } else if (this.canUseMessageChannel()) { - // For web workers, where supported - this.setImmediate = this.createMessageChannelSetImmediate(); - } else if (this.canUseReadyStateChange()) { - // For IE 6–8 - this.setImmediate = this.createReadyStateChangeSetImmediate(); - } else { - // For older browsers - this.setImmediate = this.createSetTimeoutSetImmediate(); - } - - let ci = function clearImmediate(handle: any) { - delete (clearImmediate).instance.tasksByHandle[handle]; - }; - - (ci).instance = this; - - this.clearImmediate = ci; - } - } - - canUseProcessNextTick() { - return this.identify(this.root.process) === '[object process]'; - } - - canUseMessageChannel() { - return Boolean(this.root.MessageChannel); - } - - canUseReadyStateChange() { - const document = this.root.document; - return Boolean(document && 'onreadystatechange' in document.createElement('script')); - } - - canUsePostMessage() { - const root = this.root; - // The test against `importScripts` prevents this implementation from being installed inside a web worker, - // where `root.postMessage` means something completely different and can't be used for this purpose. - if (root.postMessage && !root.importScripts) { - let postMessageIsAsynchronous = true; - let oldOnMessage = root.onmessage; - root.onmessage = function() { - postMessageIsAsynchronous = false; - }; - root.postMessage('', '*'); - root.onmessage = oldOnMessage; - return postMessageIsAsynchronous; - } - - return false; - } - - // This function accepts the same arguments as setImmediate, but - // returns a function that requires no arguments. - partiallyApplied(handler: any, ...args: any[]) { - let fn = function result () { - const { handler, args } = result; - if (typeof handler === 'function') { - handler.apply(undefined, args); - } else { - (new Function('' + handler))(); - } - }; - - (fn).handler = handler; - (fn).args = args; - - return fn; - } - - addFromSetImmediateArguments(args: any[]) { - this.tasksByHandle[this.nextHandle] = this.partiallyApplied.apply(undefined, args); - return this.nextHandle++; - } - - createProcessNextTickSetImmediate() { - let fn = function setImmediate() { - const { instance } = (setImmediate); - let handle = instance.addFromSetImmediateArguments(arguments); - instance.root.process.nextTick(instance.partiallyApplied(instance.runIfPresent, handle)); - return handle; - }; - - (fn).instance = this; - - return fn; - } - - createPostMessageSetImmediate() { - // Installs an event handler on `global` for the `message` event: see - // * https://developer.mozilla.org/en/DOM/window.postMessage - // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages - const root = this.root; - - let messagePrefix = 'setImmediate$' + root.Math.random() + '$'; - let onGlobalMessage = function globalMessageHandler(event: any) { - const instance = (globalMessageHandler).instance; - if (event.source === root && - typeof event.data === 'string' && - event.data.indexOf(messagePrefix) === 0) { - instance.runIfPresent(+event.data.slice(messagePrefix.length)); - } - }; - (onGlobalMessage).instance = this; - - root.addEventListener('message', onGlobalMessage, false); - - let fn = function setImmediate() { - const { messagePrefix, instance } = (setImmediate); - let handle = instance.addFromSetImmediateArguments(arguments); - instance.root.postMessage(messagePrefix + handle, '*'); - return handle; - }; - - (fn).instance = this; - (fn).messagePrefix = messagePrefix; - - return fn; - } - - runIfPresent(handle: any) { - // From the spec: 'Wait until any invocations of this algorithm started before this one have completed.' - // So if we're currently running a task, we'll need to delay this invocation. - if (this.currentlyRunningATask) { - // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a - // 'too much recursion' error. - this.root.setTimeout(this.partiallyApplied(this.runIfPresent, handle), 0); - } else { - let task = this.tasksByHandle[handle]; - if (task) { - this.currentlyRunningATask = true; - try { - task(); - } finally { - this.clearImmediate(handle); - this.currentlyRunningATask = false; - } - } - } - } - - createMessageChannelSetImmediate() { - let channel = new this.root.MessageChannel(); - channel.port1.onmessage = (event: any) => { - let handle = event.data; - this.runIfPresent(handle); - }; - - let fn = function setImmediate() { - const { channel, instance } = (setImmediate); - let handle = instance.addFromSetImmediateArguments(arguments); - channel.port2.postMessage(handle); - return handle; - }; - - (fn).channel = channel; - (fn).instance = this; - - return fn; - } - - createReadyStateChangeSetImmediate() { - let fn = function setImmediate() { - const instance = (setImmediate).instance; - const root = instance.root; - const doc = root.document; - const html = doc.documentElement; - - let handle = instance.addFromSetImmediateArguments(arguments); - // Create a