Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compat): fix first & last operators so undefined arguments won't … #3542

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compat/operator/first.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Observable } from 'rxjs';
import { first as higherOrder } from 'rxjs/operators';

export function first<T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean,
defaultValue?: T): Observable<T>;
/**
* Emits only the first value (or the first value that meets some condition)
* emitted by the source Observable.
Expand Down Expand Up @@ -44,7 +46,6 @@ import { first as higherOrder } from 'rxjs/operators';
* @method first
* @owner Observable
*/
export function first<T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean,
defaultValue?: T): Observable<T> {
return higherOrder(predicate, defaultValue)(this);
export function first<T>(this: Observable<T>, ...args: any[]): Observable<T> {
return higherOrder<T>(...args)(this);
}
7 changes: 4 additions & 3 deletions compat/operator/last.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Observable } from 'rxjs';
import { last as higherOrder } from 'rxjs/operators';

export function last<T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean,
defaultValue?: T): Observable<T>;
/**
* Returns an Observable that emits only the last item emitted by the source Observable.
* It optionally takes a predicate function as a parameter, in which case, rather than emitting
Expand All @@ -20,7 +22,6 @@ import { last as higherOrder } from 'rxjs/operators';
* @method last
* @owner Observable
*/
export function last<T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean,
defaultValue?: T): Observable<T> {
return higherOrder(predicate, defaultValue)(this);
export function last<T>(this: Observable<T>, ...args: any[]): Observable<T> {
return higherOrder<T>(...args)(this);
}