From 02e113b3345a9efe8f7c29f8b9c1c0d088aaf726 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 21 Sep 2020 16:32:54 -0500 Subject: [PATCH] feat(skipLast): counts zero or less will mirror the source BREAKING CHANGE: `skipLast` will no longer error when passed a negative number, rather it will simply return the source, as though `0` was passed. --- src/internal/ReplaySubject.ts | 2 +- src/internal/operators/skipLast.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/internal/ReplaySubject.ts b/src/internal/ReplaySubject.ts index 12a2fc99b4..ac71b809ff 100644 --- a/src/internal/ReplaySubject.ts +++ b/src/internal/ReplaySubject.ts @@ -81,7 +81,7 @@ export class ReplaySubject extends Subject { subscriber.next(copy[i] as T); } - this.checkFinalizedStatuses(subscriber); + this._checkFinalizedStatuses(subscriber); return subscription; } diff --git a/src/internal/operators/skipLast.ts b/src/internal/operators/skipLast.ts index 7c644d8ebf..f6a3e95b43 100644 --- a/src/internal/operators/skipLast.ts +++ b/src/internal/operators/skipLast.ts @@ -42,6 +42,7 @@ import { OperatorSubscriber } from './OperatorSubscriber'; * @name skipLast */ export function skipLast(skipCount: number): MonoTypeOperatorFunction { + // For skipCounts less than or equal to zero, we are just mirroring the source. return (source: Observable) => skipCount <= 0 ? source : lift(source, function (this: Subscriber, source: Observable) { const subscriber = this; // A ring buffer to hold the values while we wait to see