Skip to content

Commit

Permalink
Merge pull request #5729 from benlesh/refactor/smallify-all-the-things
Browse files Browse the repository at this point in the history
WIP: Refactor/smallify all the things
  • Loading branch information
benlesh authored Sep 23, 2020
2 parents 480b7c8 + 33ec81c commit fc41e13
Show file tree
Hide file tree
Showing 117 changed files with 3,507 additions and 5,593 deletions.
41 changes: 21 additions & 20 deletions api_guard/dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ export declare const async: AsyncScheduler;
export declare const asyncScheduler: AsyncScheduler;

export declare class AsyncSubject<T> extends Subject<T> {
_subscribe(subscriber: Subscriber<any>): Subscription;
protected _checkFinalizedStatuses(subscriber: Subscriber<T>): void;
complete(): void;
error(error: any): void;
next(value: T): void;
}

export declare class BehaviorSubject<T> extends Subject<T> {
get value(): T;
constructor(_value: T);
_subscribe(subscriber: Subscriber<T>): Subscription;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
getValue(): T;
next(value: T): void;
}
Expand Down Expand Up @@ -196,14 +195,14 @@ export declare const config: {
};

export declare class ConnectableObservable<T> extends Observable<T> {
protected _connection: Subscription | null | undefined;
_isComplete: boolean;
protected _connection: Subscription | null;
protected _refCount: number;
protected _subject: Subject<T> | undefined;
protected _subject: Subject<T> | null;
source: Observable<T>;
protected subjectFactory: () => Subject<T>;
constructor(source: Observable<T>, subjectFactory: () => Subject<T>);
_subscribe(subscriber: Subscriber<T>): Subscription;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
protected _teardown(): void;
connect(): Subscription;
protected getSubject(): Subject<T>;
refCount(): Observable<T>;
Expand Down Expand Up @@ -274,10 +273,8 @@ export declare function generate<S>(initialState: S, condition: ConditionFunc<S>
export declare function generate<S>(options: GenerateBaseOptions<S>): Observable<S>;
export declare function generate<T, S>(options: GenerateOptions<T, S>): Observable<T>;

export declare class GroupedObservable<K, T> extends Observable<T> {
key: K;
constructor(key: K, groupSubject: Subject<T>, refCountSubscription?: RefCountSubscription | undefined);
_subscribe(subscriber: Subscriber<T>): Subscription;
export interface GroupedObservable<K, T> extends Observable<T> {
readonly key: K;
}

export declare type Head<X extends any[]> = ((...args: X) => any) extends ((arg: infer U, ...rest: any[]) => any) ? U : never;
Expand Down Expand Up @@ -309,17 +306,17 @@ export declare function merge<T, T2, T3, T4, T5>(v1: ObservableInput<T>, v2: Obs
export declare function merge<T, T2, T3, T4, T5, T6>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>;
export declare function merge<T, T2, T3, T4, T5, T6>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, concurrent: number, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>;
export declare function merge<T>(v1: ObservableInput<T>): Observable<T>;
export declare function merge<T>(v1: ObservableInput<T>, concurrent?: number): Observable<T>;
export declare function merge<T>(v1: ObservableInput<T>, concurrent: number): Observable<T>;
export declare function merge<T, T2>(v1: ObservableInput<T>, v2: ObservableInput<T2>): Observable<T | T2>;
export declare function merge<T, T2>(v1: ObservableInput<T>, v2: ObservableInput<T2>, concurrent?: number): Observable<T | T2>;
export declare function merge<T, T2>(v1: ObservableInput<T>, v2: ObservableInput<T2>, concurrent: number): Observable<T | T2>;
export declare function merge<T, T2, T3>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>): Observable<T | T2 | T3>;
export declare function merge<T, T2, T3>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, concurrent?: number): Observable<T | T2 | T3>;
export declare function merge<T, T2, T3>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, concurrent: number): Observable<T | T2 | T3>;
export declare function merge<T, T2, T3, T4>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): Observable<T | T2 | T3 | T4>;
export declare function merge<T, T2, T3, T4>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, concurrent?: number): Observable<T | T2 | T3 | T4>;
export declare function merge<T, T2, T3, T4>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, concurrent: number): Observable<T | T2 | T3 | T4>;
export declare function merge<T, T2, T3, T4, T5>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): Observable<T | T2 | T3 | T4 | T5>;
export declare function merge<T, T2, T3, T4, T5>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, concurrent?: number): Observable<T | T2 | T3 | T4 | T5>;
export declare function merge<T, T2, T3, T4, T5>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, concurrent: number): Observable<T | T2 | T3 | T4 | T5>;
export declare function merge<T, T2, T3, T4, T5, T6>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): Observable<T | T2 | T3 | T4 | T5 | T6>;
export declare function merge<T, T2, T3, T4, T5, T6>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, concurrent?: number): Observable<T | T2 | T3 | T4 | T5 | T6>;
export declare function merge<T, T2, T3, T4, T5, T6>(v1: ObservableInput<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>, concurrent: number): Observable<T | T2 | T3 | T4 | T5 | T6>;
export declare function merge<T>(...observables: (ObservableInput<T> | number)[]): Observable<T>;
export declare function merge<T>(...observables: (ObservableInput<T> | SchedulerLike | number)[]): Observable<T>;
export declare function merge<T, R>(...observables: (ObservableInput<any> | number)[]): Observable<R>;
Expand Down Expand Up @@ -497,7 +494,8 @@ export declare function range(start?: number, count?: number, scheduler?: Schedu

export declare class ReplaySubject<T> extends Subject<T> {
constructor(bufferSize?: number, windowTime?: number, timestampProvider?: TimestampProvider);
_subscribe(subscriber: Subscriber<T>): Subscription;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
next(value: T): void;
}

export declare function scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T>;
Expand Down Expand Up @@ -529,8 +527,11 @@ export declare class Subject<T> extends Observable<T> implements SubscriptionLik
observers: Observer<T>[];
thrownError: any;
constructor();
_subscribe(subscriber: Subscriber<T>): Subscription;
_trySubscribe(subscriber: Subscriber<T>): TeardownLogic;
protected _checkFinalizedStatuses(subscriber: Subscriber<any>): void;
protected _innerSubscribe(subscriber: Subscriber<any>): Subscription;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
protected _throwIfClosed(): void;
protected _trySubscribe(subscriber: Subscriber<T>): TeardownLogic;
asObservable(): Observable<T>;
complete(): void;
error(err: any): void;
Expand Down
18 changes: 9 additions & 9 deletions api_guard/dist/types/operators/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export declare function bufferTime<T>(bufferTimeSpan: number, bufferCreationInte

export declare function bufferToggle<T, O>(openings: SubscribableOrPromise<O>, closingSelector: (value: O) => SubscribableOrPromise<any>): OperatorFunction<T, T[]>;

export declare function bufferWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, T[]>;
export declare function bufferWhen<T>(closingSelector: () => ObservableInput<any>): OperatorFunction<T, T[]>;

export declare function catchError<T, O extends ObservableInput<any>>(selector: (err: any, caught: Observable<T>) => O): OperatorFunction<T, T | ObservedValueOf<O>>;

Expand Down Expand Up @@ -180,7 +180,7 @@ export declare function mergeMapTo<T, R, O extends ObservableInput<any>>(innerOb
export declare function mergeScan<T, R>(accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, seed: R, concurrent?: number): OperatorFunction<T, R>;

export declare function mergeWith<T>(): OperatorFunction<T, T>;
export declare function mergeWith<T, A extends ObservableInput<any>[]>(...otherSources: A): OperatorFunction<T, (T | ObservedValueUnionFromArray<A>)>;
export declare function mergeWith<T, A extends ObservableInput<any>[]>(...otherSources: A): OperatorFunction<T, T | ObservedValueUnionFromArray<A>>;

export declare function min<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T>;

Expand Down Expand Up @@ -260,7 +260,7 @@ export declare function single<T>(predicate?: (value: T, index: number, source:

export declare function skip<T>(count: number): MonoTypeOperatorFunction<T>;

export declare function skipLast<T>(count: number): MonoTypeOperatorFunction<T>;
export declare function skipLast<T>(skipCount: number): MonoTypeOperatorFunction<T>;

export declare function skipUntil<T>(notifier: Observable<any>): MonoTypeOperatorFunction<T>;

Expand Down Expand Up @@ -292,7 +292,7 @@ export declare function take<T>(count: number): MonoTypeOperatorFunction<T>;

export declare function takeLast<T>(count: number): MonoTypeOperatorFunction<T>;

export declare function takeUntil<T>(notifier: Observable<any>): MonoTypeOperatorFunction<T>;
export declare function takeUntil<T>(notifier: ObservableInput<any>): MonoTypeOperatorFunction<T>;

export declare function takeWhile<T, S extends T>(predicate: (value: T, index: number) => value is S): OperatorFunction<T, S>;
export declare function takeWhile<T, S extends T>(predicate: (value: T, index: number) => value is S, inclusive: false): OperatorFunction<T, S>;
Expand All @@ -304,11 +304,11 @@ export declare function tap<T>(next: (value: T) => void, error: null | undefined
export declare function tap<T>(next?: (x: T) => void, error?: (e: any) => void, complete?: () => void): MonoTypeOperatorFunction<T>;
export declare function tap<T>(observer: PartialObserver<T>): MonoTypeOperatorFunction<T>;

export declare function throttle<T>(durationSelector: (value: T) => SubscribableOrPromise<any>, config?: ThrottleConfig): MonoTypeOperatorFunction<T>;
export declare function throttle<T>(durationSelector: (value: T) => SubscribableOrPromise<any>, { leading, trailing }?: ThrottleConfig): MonoTypeOperatorFunction<T>;

export declare function throttleTime<T>(duration: number, scheduler?: SchedulerLike, { leading, trailing }?: ThrottleConfig): MonoTypeOperatorFunction<T>;

export declare function throwIfEmpty<T>(errorFactory?: (() => any)): MonoTypeOperatorFunction<T>;
export declare function throwIfEmpty<T>(errorFactory?: () => any): MonoTypeOperatorFunction<T>;

export declare function timeInterval<T>(scheduler?: SchedulerLike): OperatorFunction<T, TimeInterval<T>>;

Expand All @@ -332,11 +332,11 @@ export declare function windowCount<T>(windowSize: number, startWindowEvery?: nu

export declare function windowTime<T>(windowTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number | null | void, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;

export declare function windowToggle<T, O>(openings: Observable<O>, closingSelector: (openValue: O) => Observable<any>): OperatorFunction<T, Observable<T>>;
export declare function windowToggle<T, O>(openings: ObservableInput<O>, closingSelector: (openValue: O) => ObservableInput<any>): OperatorFunction<T, Observable<T>>;

export declare function windowWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, Observable<T>>;
export declare function windowWhen<T>(closingSelector: () => ObservableInput<any>): OperatorFunction<T, Observable<T>>;

export declare function withLatestFrom<T, R>(project: (v1: T) => R): OperatorFunction<T, R>;
export declare function withLatestFrom<T, O2 extends ObservableInput<any>, R>(source2: O2, project: (v1: T, v2: ObservedValueOf<O2>) => R): OperatorFunction<T, R>;
Expand Down
184 changes: 0 additions & 184 deletions spec/observables/IteratorObservable-spec.ts

This file was deleted.

45 changes: 45 additions & 0 deletions spec/observables/fromEvent-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,49 @@ describe('fromEvent', () => {
}).to.not.throw(TypeError);
});

it('should handle adding events to an arraylike of targets', () => {
const nodeList = {
[0]: {
addEventListener(...args: any[]) {
this._addEventListenerArgs = args;
},
removeEventListener(...args: any[]) {
this._removeEventListenerArgs = args;
},
_addEventListenerArgs: null as any,
_removeEventListenerArgs: null as any,
},
[1]: {
addEventListener(...args: any[]) {
this._addEventListenerArgs = args;
},
removeEventListener(...args: any[]) {
this._removeEventListenerArgs = args;
},
_addEventListenerArgs: null as any,
_removeEventListenerArgs: null as any,
},
length: 2
};

const options = {};

const subscription = fromEvent(nodeList, 'click', options).subscribe();

expect(nodeList[0]._addEventListenerArgs[0]).to.equal('click');
expect(nodeList[0]._addEventListenerArgs[1]).to.be.a('function');
expect(nodeList[0]._addEventListenerArgs[2]).to.equal(options);

expect(nodeList[1]._addEventListenerArgs[0]).to.equal('click');
expect(nodeList[1]._addEventListenerArgs[1]).to.be.a('function');
expect(nodeList[1]._addEventListenerArgs[2]).to.equal(options);

expect(nodeList[0]._removeEventListenerArgs).to.be.null;
expect(nodeList[1]._removeEventListenerArgs).to.be.null;

subscription.unsubscribe();

expect(nodeList[0]._removeEventListenerArgs).to.deep.equal(nodeList[0]._addEventListenerArgs);
expect(nodeList[1]._removeEventListenerArgs).to.deep.equal(nodeList[1]._addEventListenerArgs);
});
});
Loading

0 comments on commit fc41e13

Please sign in to comment.