Opal-Estate-Pro/node_modules/rxjs/operators/takeLast.js.map
2019-09-13 11:27:52 +07:00

1 line
5.6 KiB
Plaintext
Executable File

{"version":3,"file":"takeLast.js","sourceRoot":"","sources":["../../src/operators/takeLast.ts"],"names":[],"mappings":";;;;;;AACA,2BAA2B,eAAe,CAAC,CAAA;AAC3C,wCAAwC,iCAAiC,CAAC,CAAA;AAC1E,gCAAgC,+BAA+B,CAAC,CAAA;AAKhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,kBAA4B,KAAa;IACvC,MAAM,CAAC,kCAAkC,MAAqB;QAC5D,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,IAAI,iCAAe,EAAK,CAAC;QAClC,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AARe,gBAAQ,WAQvB,CAAA;AAED;IACE,0BAAoB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAC/B,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,MAAM,IAAI,iDAAuB,CAAC;QACpC,CAAC;IACH,CAAC;IAED,+BAAI,GAAJ,UAAK,UAAyB,EAAE,MAAW;QACzC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1E,CAAC;IACH,uBAAC;AAAD,CAAC,AAVD,IAUC;AAED;;;;GAIG;AACH;IAAoC,sCAAa;IAI/C,4BAAY,WAA0B,EAAU,KAAa;QAC3D,kBAAM,WAAW,CAAC,CAAC;QAD2B,UAAK,GAAL,KAAK,CAAQ;QAHrD,SAAI,GAAa,IAAI,KAAK,EAAE,CAA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'../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';\nimport { EmptyObservable } from '../observable/EmptyObservable';\nimport { Observable } from '../Observable';\nimport { TeardownLogic } from '../Subscription';\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * Emits only the last `count` values emitted by the source Observable.\n *\n * <span class=\"informal\">Remembers the latest `count` values, then emits those\n * only when the source completes.</span>\n *\n * <img src=\"./img/takeLast.png\" width=\"100%\">\n *\n * `takeLast` returns an Observable that emits at most the last `count` values\n * emitted by the source Observable. If the source emits fewer than `count`\n * values then all of its values are emitted. This operator must wait until the\n * `complete` notification emission from the source in order to emit the `next`\n * values on the output Observable, because otherwise it is impossible to know\n * whether or not more values will be emitted on the source. For this reason,\n * all values are emitted synchronously, followed by the complete notification.\n *\n * @example <caption>Take the last 3 values of an Observable with many values</caption>\n * var many = Rx.Observable.range(1, 100);\n * var lastThree = many.takeLast(3);\n * lastThree.subscribe(x => console.log(x));\n *\n * @see {@link take}\n * @see {@link takeUntil}\n * @see {@link takeWhile}\n * @see {@link skip}\n *\n * @throws {ArgumentOutOfRangeError} When using `takeLast(i)`, it delivers an\n * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.\n *\n * @param {number} count The maximum number of values to emit from the end of\n * the sequence of values emitted by the source Observable.\n * @return {Observable<T>} An Observable that emits at most the last count\n * values emitted by the source Observable.\n * @method takeLast\n * @owner Observable\n */\nexport function takeLast<T>(count: number): MonoTypeOperatorFunction<T> {\n return function takeLastOperatorFunction(source: Observable<T>): Observable<T> {\n if (count === 0) {\n return new EmptyObservable<T>();\n } else {\n return source.lift(new TakeLastOperator(count));\n }\n };\n}\n\nclass TakeLastOperator<T> implements Operator<T, T> {\n constructor(private total: number) {\n if (this.total < 0) {\n throw new ArgumentOutOfRangeError;\n }\n }\n\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n return source.subscribe(new TakeLastSubscriber(subscriber, this.total));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass TakeLastSubscriber<T> extends Subscriber<T> {\n private ring: Array<T> = new Array();\n private count: number = 0;\n\n constructor(destination: Subscriber<T>, private total: number) {\n super(destination);\n }\n\n protected _next(value: T): void {\n const ring = this.ring;\n const total = this.total;\n const count = this.count++;\n\n if (ring.length < total) {\n ring.push(value);\n } else {\n const index = count % total;\n ring[index] = value;\n }\n }\n\n protected _complete(): void {\n const destination = this.destination;\n let count = this.count;\n\n if (count > 0) {\n const total = this.count >= this.total ? this.total : this.count;\n const ring = this.ring;\n\n for (let i = 0; i < total; i++) {\n const idx = (count++) % total;\n destination.next(ring[idx]);\n }\n }\n\n destination.complete();\n }\n}\n"]}