Subtheme of barrio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
2.8 KiB

{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/operator/scan.ts"],"names":[],"mappings":";AAEA,qBAAwC,mBAAmB,CAAC,CAAA;AAM5D,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,cAAgD,WAAmD,EAAE,IAAY;IAC/G,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,CAAC,WAAe,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAkB,CAAC;IACnE,CAAC;IACD,MAAM,CAAC,WAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AALe,YAAI,OAKnB,CAAA","sourcesContent":["\nimport { Observable } from '../Observable';\nimport { scan as higherOrderScan } from '../operators/scan';\n\n/* tslint:disable:max-line-length */\nexport function scan<T>(this: Observable<T>, accumulator: (acc: T, value: T, index: number) => T, seed?: T): Observable<T>;\nexport function scan<T>(this: Observable<T>, accumulator: (acc: T[], value: T, index: number) => T[], seed?: T[]): Observable<T[]>;\nexport function scan<T, R>(this: Observable<T>, accumulator: (acc: R, value: T, index: number) => R, seed?: R): Observable<R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Applies an accumulator function over the source Observable, and returns each\n * intermediate result, with an optional seed value.\n *\n * <span class=\"informal\">It's like {@link reduce}, but emits the current\n * accumulation whenever the source emits a value.</span>\n *\n * <img src=\"./img/scan.png\" width=\"100%\">\n *\n * Combines together all values emitted on the source, using an accumulator\n * function that knows how to join a new source value into the accumulation from\n * the past. Is similar to {@link reduce}, but emits the intermediate\n * accumulations.\n *\n * Returns an Observable that applies a specified `accumulator` function to each\n * item emitted by the source Observable. If a `seed` value is specified, then\n * that value will be used as the initial value for the accumulator. If no seed\n * value is specified, the first item of the source is used as the seed.\n *\n * @example <caption>Count the number of click events</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var ones = clicks.mapTo(1);\n * var seed = 0;\n * var count = ones.scan((acc, one) => acc + one, seed);\n * count.subscribe(x => console.log(x));\n *\n * @see {@link expand}\n * @see {@link mergeScan}\n * @see {@link reduce}\n *\n * @param {function(acc: R, value: T, index: number): R} accumulator\n * The accumulator function called on each source value.\n * @param {T|R} [seed] The initial accumulation value.\n * @return {Observable<R>} An observable of the accumulated values.\n * @method scan\n * @owner Observable\n */\nexport function scan<T, R>(this: Observable<T>, accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable<R> {\n if (arguments.length >= 2) {\n return higherOrderScan(accumulator, seed)(this) as Observable<R>;\n }\n return higherOrderScan(accumulator)(this);\n}\n"]}