Sha256: a216211513af58625915d0075802e366809192e2f55e9335cdf49d86be18db05

Contents?: true

Size: 1.8 KB

Versions: 49

Compression:

Stored size: 1.8 KB

Contents

"use strict";
var scan_1 = require('../operators/scan');
/* tslint:enable:max-line-length */
/**
 * Applies an accumulator function over the source Observable, and returns each
 * intermediate result, with an optional seed value.
 *
 * <span class="informal">It's like {@link reduce}, but emits the current
 * accumulation whenever the source emits a value.</span>
 *
 * <img src="./img/scan.png" width="100%">
 *
 * Combines together all values emitted on the source, using an accumulator
 * function that knows how to join a new source value into the accumulation from
 * the past. Is similar to {@link reduce}, but emits the intermediate
 * accumulations.
 *
 * Returns an Observable that applies a specified `accumulator` function to each
 * item emitted by the source Observable. If a `seed` value is specified, then
 * that value will be used as the initial value for the accumulator. If no seed
 * value is specified, the first item of the source is used as the seed.
 *
 * @example <caption>Count the number of click events</caption>
 * var clicks = Rx.Observable.fromEvent(document, 'click');
 * var ones = clicks.mapTo(1);
 * var seed = 0;
 * var count = ones.scan((acc, one) => acc + one, seed);
 * count.subscribe(x => console.log(x));
 *
 * @see {@link expand}
 * @see {@link mergeScan}
 * @see {@link reduce}
 *
 * @param {function(acc: R, value: T, index: number): R} accumulator
 * The accumulator function called on each source value.
 * @param {T|R} [seed] The initial accumulation value.
 * @return {Observable<R>} An observable of the accumulated values.
 * @method scan
 * @owner Observable
 */
function scan(accumulator, seed) {
    if (arguments.length >= 2) {
        return scan_1.scan(accumulator, seed)(this);
    }
    return scan_1.scan(accumulator)(this);
}
exports.scan = scan;
//# sourceMappingURL=scan.js.map

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/rxjs/operator/scan.js
ilog-0.4.0 node_modules/rxjs/operator/scan.js
ilog-0.3.3 node_modules/rxjs/operator/scan.js
govuk_publishing_components-18.0.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.21.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.20.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.19.1 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.19.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.18.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.17.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.16.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.15.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.14.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.13.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.12.2 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.12.1 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.12.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.11.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.10.0 node_modules/rxjs/operator/scan.js
govuk_publishing_components-17.9.0 node_modules/rxjs/operator/scan.js