Skip to content

Commit

Permalink
refactor(OperatorFunction): update appropriate operators to MonoTypeO…
Browse files Browse the repository at this point in the history
…peratorFunction
  • Loading branch information
benlesh committed Jun 16, 2017
1 parent fb6014d commit 1109697
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/operators/defaultIfEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Operator } from '../Operator';
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { OperatorFunction } from '../interfaces';
import { OperatorFunction, MonoTypeOperatorFunction } from '../interfaces';

/* tslint:disable:max-line-length */
export function defaultIfEmpty<T>(defaultValue?: T): OperatorFunction<T, T>;
export function defaultIfEmpty<T>(defaultValue?: T): MonoTypeOperatorFunction<T>;
export function defaultIfEmpty<T, R>(defaultValue?: R): OperatorFunction<T, T | R>;
/* tslint:enable:max-line-length */

Expand Down
6 changes: 3 additions & 3 deletions src/operators/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Operator } from '../Operator';
import { Subscriber } from '../Subscriber';
import { Observable } from '../Observable';
import { TeardownLogic } from '../Subscription';
import { OperatorFunction } from '../interfaces';
import { OperatorFunction, MonoTypeOperatorFunction } from '../interfaces';

/* tslint:disable:max-line-length */
export function filter<T, S extends T>(predicate: (value: T, index: number) => value is S,
thisArg?: any): OperatorFunction<T, S>;
export function filter<T>(predicate: (value: T, index: number) => boolean,
thisArg?: any): OperatorFunction<T, T>;
thisArg?: any): MonoTypeOperatorFunction<T>;
/* tslint:enable:max-line-length */

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ export function filter<T>(predicate: (value: T, index: number) => boolean,
* @owner Observable
*/
export function filter<T>(predicate: (value: T, index: number) => boolean,
thisArg?: any): OperatorFunction<T, T> {
thisArg?: any): MonoTypeOperatorFunction<T> {
return function filterOperatorFunction(source: Observable<T>): Observable<T> {
return source.lift(new FilterOperator(predicate, thisArg));
};
Expand Down
4 changes: 2 additions & 2 deletions src/operators/max.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reduce } from './reduce';
import { OperatorFunction } from '../interfaces';
import { MonoTypeOperatorFunction } from '../interfaces';

/**
* The Max operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
Expand Down Expand Up @@ -32,7 +32,7 @@ import { OperatorFunction } from '../interfaces';
* @method max
* @owner Observable
*/
export function max<T>(comparer?: (x: T, y: T) => number): OperatorFunction<T, T> {
export function max<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T> {
const max: (x: T, y: T) => T = (typeof comparer === 'function')
? (x, y) => comparer(x, y) > 0 ? x : y
: (x, y) => x > y ? x : y;
Expand Down
4 changes: 2 additions & 2 deletions src/operators/min.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reduce } from './reduce';
import { OperatorFunction } from '../interfaces';
import { MonoTypeOperatorFunction } from '../interfaces';

/**
* The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function),
Expand Down Expand Up @@ -32,7 +32,7 @@ import { OperatorFunction } from '../interfaces';
* @method min
* @owner Observable
*/
export function min<T>(comparer?: (x: T, y: T) => number): OperatorFunction<T, T> {
export function min<T>(comparer?: (x: T, y: T) => number): MonoTypeOperatorFunction<T> {
const min: (x: T, y: T) => T = (typeof comparer === 'function')
? (x, y) => comparer(x, y) < 0 ? x : y
: (x, y) => x < y ? x : y;
Expand Down
4 changes: 2 additions & 2 deletions src/operators/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Observable } from '../Observable';
import { scan } from './scan';
import { takeLast } from './takeLast';
import { defaultIfEmpty } from './defaultIfEmpty';
import { OperatorFunction } from '../interfaces';
import { OperatorFunction, MonoTypeOperatorFunction } from '../interfaces';
import { compose } from '../util/compose';

/* tslint:disable:max-line-length */
export function reduce<T>(accumulator: (acc: T, value: T, index: number) => T, seed?: T): OperatorFunction<T, T>;
export function reduce<T>(accumulator: (acc: T, value: T, index: number) => T, seed?: T): MonoTypeOperatorFunction<T>;
export function reduce<T>(accumulator: (acc: T[], value: T, index: number) => T[], seed: T[]): OperatorFunction<T, T[]>;
export function reduce<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed?: R): OperatorFunction<T, R>;
/* tslint:enable:max-line-length */
Expand Down
4 changes: 2 additions & 2 deletions src/operators/scan.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Operator } from '../Operator';
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { OperatorFunction } from '../interfaces';
import { OperatorFunction, MonoTypeOperatorFunction } from '../interfaces';

/* tslint:disable:max-line-length */
export function scan<T>(accumulator: (acc: T, value: T, index: number) => T, seed?: T): OperatorFunction<T, T>;
export function scan<T>(accumulator: (acc: T, value: T, index: number) => T, seed?: T): MonoTypeOperatorFunction<T>;
export function scan<T>(accumulator: (acc: T[], value: T, index: number) => T[], seed?: T[]): OperatorFunction<T, T[]>;
export function scan<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed?: R): OperatorFunction<T, R>;
/* tslint:enable:max-line-length */
Expand Down
4 changes: 2 additions & 2 deletions src/operators/takeLast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
import { EmptyObservable } from '../observable/EmptyObservable';
import { Observable } from '../Observable';
import { TeardownLogic } from '../Subscription';
import { OperatorFunction } from '../interfaces';
import { MonoTypeOperatorFunction } from '../interfaces';

/**
* Emits only the last `count` values emitted by the source Observable.
Expand Down Expand Up @@ -42,7 +42,7 @@ import { OperatorFunction } from '../interfaces';
* @method takeLast
* @owner Observable
*/
export function takeLast<T>(count: number): OperatorFunction<T, T> {
export function takeLast<T>(count: number): MonoTypeOperatorFunction<T> {
return function takeLastOperatorFunction(source: Observable<T>): Observable<T> {
if (count === 0) {
return new EmptyObservable<T>();
Expand Down

0 comments on commit 1109697

Please sign in to comment.