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

1 line
5.4 KiB
Plaintext
Executable File

{"version":3,"file":"count.js","sourceRoot":"","sources":["../../src/operators/count.ts"],"names":[],"mappings":";;;;;;AAGA,2BAA2B,eAAe,CAAC,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAyB,SAAuE;IAC9F,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,EAAjD,CAAiD,CAAC;AACtF,CAAC;AAFe,aAAK,QAEpB,CAAA;AAED;IACE,uBAAoB,SAAuE,EACvE,MAAsB;QADtB,cAAS,GAAT,SAAS,CAA8D;QACvE,WAAM,GAAN,MAAM,CAAgB;IAC1C,CAAC;IAED,4BAAI,GAAJ,UAAK,UAA8B,EAAE,MAAW;QAC9C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AARD,IAQC;AAED;;;;GAIG;AACH;IAAiC,mCAAa;IAI5C,yBAAY,WAA6B,EACrB,SAAuE,EACvE,MAAsB;QACxC,kBAAM,WAAW,CAAC,CAAC;QAFD,cAAS,GAAT,SAAS,CAA8D;QACvE,WAAM,GAAN,MAAM,CAAgB;QALlC,UAAK,GAAW,CAAC,CAAC;QAClB,UAAK,GAAW,CAAC,CAAC;IAM1B,CAAC;IAES,+BAAK,GAAf,UAAgB,KAAQ;QACtB,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAEO,uCAAa,GAArB,UAAsB,KAAQ;QAC5B,IAAI,MAAW,CAAC;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,CAAC;QACT,CAAC;QAED,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACX,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAES,mCAAS,GAAnB;QACE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IACH,sBAAC;AAAD,CAAC,AArCD,CAAiC,uBAAU,GAqC1C","sourcesContent":["import { Observable } from '../Observable';\nimport { Operator } from '../Operator';\nimport { Observer } from '../Observer';\nimport { Subscriber } from '../Subscriber';\nimport { OperatorFunction } from '../interfaces';\n\n/**\n * Counts the number of emissions on the source and emits that number when the\n * source completes.\n *\n * <span class=\"informal\">Tells how many values were emitted, when the source\n * completes.</span>\n *\n * <img src=\"./img/count.png\" width=\"100%\">\n *\n * `count` transforms an Observable that emits values into an Observable that\n * emits a single value that represents the number of values emitted by the\n * source Observable. If the source Observable terminates with an error, `count`\n * will pass this error notification along without emitting a value first. If\n * the source Observable does not terminate at all, `count` will neither emit\n * a value nor terminate. This operator takes an optional `predicate` function\n * as argument, in which case the output emission will represent the number of\n * source values that matched `true` with the `predicate`.\n *\n * @example <caption>Counts how many seconds have passed before the first click happened</caption>\n * var seconds = Rx.Observable.interval(1000);\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var secondsBeforeClick = seconds.takeUntil(clicks);\n * var result = secondsBeforeClick.count();\n * result.subscribe(x => console.log(x));\n *\n * @example <caption>Counts how many odd numbers are there between 1 and 7</caption>\n * var numbers = Rx.Observable.range(1, 7);\n * var result = numbers.count(i => i % 2 === 1);\n * result.subscribe(x => console.log(x));\n *\n * // Results in:\n * // 4\n *\n * @see {@link max}\n * @see {@link min}\n * @see {@link reduce}\n *\n * @param {function(value: T, i: number, source: Observable<T>): boolean} [predicate] A\n * boolean function to select what values are to be counted. It is provided with\n * arguments of:\n * - `value`: the value from the source Observable.\n * - `index`: the (zero-based) \"index\" of the value from the source Observable.\n * - `source`: the source Observable instance itself.\n * @return {Observable} An Observable of one number that represents the count as\n * described above.\n * @method count\n * @owner Observable\n */\nexport function count<T>(predicate?: (value: T, index: number, source: Observable<T>) => boolean): OperatorFunction<T, number> {\n return (source: Observable<T>) => source.lift(new CountOperator(predicate, source));\n}\n\nclass CountOperator<T> implements Operator<T, number> {\n constructor(private predicate?: (value: T, index: number, source: Observable<T>) => boolean,\n private source?: Observable<T>) {\n }\n\n call(subscriber: Subscriber<number>, source: any): any {\n return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass CountSubscriber<T> extends Subscriber<T> {\n private count: number = 0;\n private index: number = 0;\n\n constructor(destination: Observer<number>,\n private predicate?: (value: T, index: number, source: Observable<T>) => boolean,\n private source?: Observable<T>) {\n super(destination);\n }\n\n protected _next(value: T): void {\n if (this.predicate) {\n this._tryPredicate(value);\n } else {\n this.count++;\n }\n }\n\n private _tryPredicate(value: T) {\n let result: any;\n\n try {\n result = this.predicate(value, this.index++, this.source);\n } catch (err) {\n this.destination.error(err);\n return;\n }\n\n if (result) {\n this.count++;\n }\n }\n\n protected _complete(): void {\n this.destination.next(this.count);\n this.destination.complete();\n }\n}\n"]}