Tumortisch-Dist/resources/app/node_modules/rxjs/operators/pairwise.js.map

1 line
3.3 KiB
Plaintext
Raw Permalink Normal View History

2021-06-15 16:00:08 +02:00
{"version":3,"file":"pairwise.js","sourceRoot":"","sources":["../../src/operators/pairwise.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA2B,eAAe,CAAC,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH;IACE,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,EAAE,CAAC,EAAnC,CAAmC,CAAC;AACxE,CAAC;AAFe,gBAAQ,WAEvB,CAAA;AAED;IAAA;IAIA,CAAC;IAHC,+BAAI,GAAJ,UAAK,UAA8B,EAAE,MAAW;QAC9C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9D,CAAC;IACH,uBAAC;AAAD,CAAC,AAJD,IAIC;AAED;;;;GAIG;AACH;IAAoC,sCAAa;IAI/C,4BAAY,WAA+B;QACzC,kBAAM,WAAW,CAAC,CAAC;QAHb,YAAO,GAAY,KAAK,CAAC;IAIjC,CAAC;IAED,kCAAK,GAAL,UAAM,KAAQ;QACZ,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IACH,yBAAC;AAAD,CAAC,AAjBD,CAAoC,uBAAU,GAiB7C","sourcesContent":["import { Operator } from '../Operator';\nimport { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../interfaces';\n\n/**\n * Groups pairs of consecutive emissions together and emits them as an array of\n * two values.\n *\n * <span class=\"informal\">Puts the current value and previous value together as\n * an array, and emits that.</span>\n *\n * <img src=\"./img/pairwise.png\" width=\"100%\">\n *\n * The Nth emission from the source Observable will cause the output Observable\n * to emit an array [(N-1)th, Nth] of the previous and the current value, as a\n * pair. For this reason, `pairwise` emits on the second and subsequent\n * emissions from the source Observable, but not on the first emission, because\n * there is no previous value in that case.\n *\n * @example <caption>On every click (starting from the second), emit the relative distance to the previous click</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var pairs = clicks.pairwise();\n * var distance = pairs.map(pair => {\n * var x0 = pair[0].clientX;\n * var y0 = pair[0].clientY;\n * var x1 = pair[1].clientX;\n * var y1 = pair[1].clientY;\n * return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));\n * });\n * distance.subscribe(x => console.log(x));\n *\n * @see {@link buffer}\n * @see {@link bufferCount}\n *\n * @return {Observable<Array<T>>} An Observable of pairs (as arrays) of\n * consecutive values from the source Observable.\n * @method pairwise\n * @owner Observable\n */\nexport function pairwise<T>(): OperatorFunction<T, [T, T]> {\n return (source: Observable<T>) => source.lift(new PairwiseOperator());\n}\n\nclass PairwiseOperator<T> implements Operator<T, [T, T]> {\n call(subscriber: Subscriber<[T, T]>, source: any): any {\n return source.subscribe(new PairwiseSubscriber(subscriber));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass PairwiseSubscriber<T> extends Subscriber<T> {\n private prev: T;\n private hasPrev: boolean = false;\n\n constructor(destination: Subscriber<[T, T]>) {\n super(destination);\n }\n\n _next(value: T): void {\n if (this.hasPrev) {\n this.destination.next([this.prev, value]);\n } else {\n this.hasPrev = true;\n }\n\n this.prev = value;\n }\n}\n"]}