Skip to content

Commit

Permalink
feat(skipLast): counts zero or less will mirror the source
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `skipLast` will no longer error when passed a negative number, rather it will simply return the source, as though `0` was passed.
  • Loading branch information
benlesh committed Sep 21, 2020
1 parent 29dd6ec commit 02e113b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/internal/ReplaySubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ReplaySubject<T> extends Subject<T> {
subscriber.next(copy[i] as T);
}

this.checkFinalizedStatuses(subscriber);
this._checkFinalizedStatuses(subscriber);

return subscription;
}
Expand Down
1 change: 1 addition & 0 deletions src/internal/operators/skipLast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { OperatorSubscriber } from './OperatorSubscriber';
* @name skipLast
*/
export function skipLast<T>(skipCount: number): MonoTypeOperatorFunction<T> {
// For skipCounts less than or equal to zero, we are just mirroring the source.
return (source: Observable<T>) => skipCount <= 0 ? source : lift(source, function (this: Subscriber<T>, source: Observable<T>) {
const subscriber = this;
// A ring buffer to hold the values while we wait to see
Expand Down

0 comments on commit 02e113b

Please sign in to comment.