PATH:
usr
/
local
/
lib
/
node_modules
/
ghost-cli
/
node_modules
/
rxjs
/
src
/
internal
/
operators
import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError'; import { Observable } from '../Observable'; import { MonoTypeOperatorFunction, TeardownLogic } from '../types'; /** * Skip the last `count` values emitted by the source Observable. * *  * * `skipLast` returns an Observable that accumulates a queue with a length * enough to store the first `count` values. As more values are received, * values are taken from the front of the queue and produced on the result * sequence. This causes values to be delayed. * * ## Example * Skip the last 2 values of an Observable with many values * ```ts * import { range } from 'rxjs'; * import { skipLast } from 'rxjs/operators'; * * const many = range(1, 5); * const skipLastTwo = many.pipe(skipLast(2)); * skipLastTwo.subscribe(x => console.log(x)); * * // Results in: * // 1 2 3 * ``` * * @see {@link skip} * @see {@link skipUntil} * @see {@link skipWhile} * @see {@link take} * * @throws {ArgumentOutOfRangeError} When using `skipLast(i)`, it throws * ArgumentOutOrRangeError if `i < 0`. * * @param {number} count Number of elements to skip from the end of the source Observable. * @returns {Observable<T>} An Observable that skips the last count values * emitted by the source Observable. * @method skipLast * @owner Observable */ export function skipLast<T>(count: number): MonoTypeOperatorFunction<T> { return (source: Observable<T>) => source.lift(new SkipLastOperator(count)); } class SkipLastOperator<T> implements Operator<T, T> { constructor(private _skipCount: number) { if (this._skipCount < 0) { throw new ArgumentOutOfRangeError; } } call(subscriber: Subscriber<T>, source: any): TeardownLogic { if (this._skipCount === 0) { // If we don't want to skip any values then just subscribe // to Subscriber without any further logic. return source.subscribe(new Subscriber(subscriber)); } else { return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount)); } } } /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ class SkipLastSubscriber<T> extends Subscriber<T> { private _ring: T[]; private _count: number = 0; constructor(destination: Subscriber<T>, private _skipCount: number) { super(destination); this._ring = new Array<T>(_skipCount); } protected _next(value: T): void { const skipCount = this._skipCount; const count = this._count++; if (count < skipCount) { this._ring[count] = value; } else { const currentIndex = count % skipCount; const ring = this._ring; const oldValue = ring[currentIndex]; ring[currentIndex] = value; this.destination.next(oldValue); } } }
[-] toArray.ts
[edit]
[-] window.ts
[edit]
[-] retry.ts
[edit]
[-] mergeAll.ts
[edit]
[-] windowWhen.ts
[edit]
[-] every.ts
[edit]
[-] timeout.ts
[edit]
[-] debounceTime.ts
[edit]
[-] index.ts
[edit]
[-] takeWhile.ts
[edit]
[-] audit.ts
[edit]
[-] reduce.ts
[edit]
[-] mapTo.ts
[edit]
[-] count.ts
[edit]
[-] debounce.ts
[edit]
[-] throwIfEmpty.ts
[edit]
[-] auditTime.ts
[edit]
[-] scan.ts
[edit]
[-] switchAll.ts
[edit]
[-] map.ts
[edit]
[-] bufferCount.ts
[edit]
[-] mergeScan.ts
[edit]
[-] publish.ts
[edit]
[-] min.ts
[edit]
[+]
..
[-] publishReplay.ts
[edit]
[-] bufferTime.ts
[edit]
[-] share.ts
[edit]
[-] repeat.ts
[edit]
[-] distinct.ts
[edit]
[-] concatMapTo.ts
[edit]
[-] buffer.ts
[edit]
[-] concatMap.ts
[edit]
[-] max.ts
[edit]
[-] partition.ts
[edit]
[-] observeOn.ts
[edit]
[-] bufferWhen.ts
[edit]
[-] dematerialize.ts
[edit]
[-] throttle.ts
[edit]
[-] groupBy.ts
[edit]
[-] withLatestFrom.ts
[edit]
[-] exhaust.ts
[edit]
[-] exhaustMap.ts
[edit]
[-] retryWhen.ts
[edit]
[-] zipAll.ts
[edit]
[-] find.ts
[edit]
[-] mergeMap.ts
[edit]
[-] single.ts
[edit]
[-] last.ts
[edit]
[-] combineLatest.ts
[edit]
[-] publishLast.ts
[edit]
[-] pluck.ts
[edit]
[-] pairwise.ts
[edit]
[-] distinctUntilChanged.ts
[edit]
[-] timeInterval.ts
[edit]
[-] shareReplay.ts
[edit]
[-] skipUntil.ts
[edit]
[-] findIndex.ts
[edit]
[-] windowToggle.ts
[edit]
[-] startWith.ts
[edit]
[-] timeoutWith.ts
[edit]
[-] concat.ts
[edit]
[-] materialize.ts
[edit]
[-] timestamp.ts
[edit]
[-] onErrorResumeNext.ts
[edit]
[-] subscribeOn.ts
[edit]
[-] takeUntil.ts
[edit]
[-] skipLast.ts
[edit]
[-] throttleTime.ts
[edit]
[-] mergeMapTo.ts
[edit]
[-] multicast.ts
[edit]
[-] merge.ts
[edit]
[-] takeLast.ts
[edit]
[-] delayWhen.ts
[edit]
[-] sampleTime.ts
[edit]
[-] tap.ts
[edit]
[-] take.ts
[edit]
[-] sample.ts
[edit]
[-] filter.ts
[edit]
[-] skip.ts
[edit]
[-] expand.ts
[edit]
[-] publishBehavior.ts
[edit]
[-] sequenceEqual.ts
[edit]
[-] ignoreElements.ts
[edit]
[-] catchError.ts
[edit]
[-] endWith.ts
[edit]
[-] refCount.ts
[edit]
[-] windowCount.ts
[edit]
[-] defaultIfEmpty.ts
[edit]
[-] windowTime.ts
[edit]
[-] switchMapTo.ts
[edit]
[-] switchMap.ts
[edit]
[-] delay.ts
[edit]
[-] bufferToggle.ts
[edit]
[-] repeatWhen.ts
[edit]
[-] concatAll.ts
[edit]
[-] first.ts
[edit]
[-] zip.ts
[edit]
[-] elementAt.ts
[edit]
[-] skipWhile.ts
[edit]
[-] race.ts
[edit]
[-] finalize.ts
[edit]
[-] combineAll.ts
[edit]
[-] distinctUntilKeyChanged.ts
[edit]
[-] isEmpty.ts
[edit]