Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/rxjs/src/operators/ |
Upload File : |
import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError'; import { Observable } from '../Observable'; import { TeardownLogic } from '../Subscription'; import { MonoTypeOperatorFunction } from '../interfaces'; /** * Skip the last `count` values emitted by the source Observable. * * <img src="./img/skipLast.png" width="100%"> * * `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 <caption>Skip the last 2 values of an Observable with many values</caption> * var many = Rx.Observable.range(1, 5); * var skipLastTwo = many.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); } } }