diff --git a/rx/rx-lite-tests.ts b/rx/rx-lite-tests.ts new file mode 100644 index 0000000000..9949fa2ea8 --- /dev/null +++ b/rx/rx-lite-tests.ts @@ -0,0 +1,13 @@ +/// +function test_scan() { + + /* Without a seed */ + const source1: Rx.Observable = Rx.Observable.range(1, 3) + .scan((acc, x, i, source) => acc + x); + + /* With a seed */ + const source2: Rx.Observable = Rx.Observable.range(1, 3) + .scan((acc, x, i, source) => acc + x, '...'); + +} + diff --git a/rx/rx-lite.d.ts b/rx/rx-lite.d.ts index 10aec5d791..14f40fdb39 100644 --- a/rx/rx-lite.d.ts +++ b/rx/rx-lite.d.ts @@ -323,8 +323,20 @@ declare module Rx { materialize(): Observable>; repeat(repeatCount?: number): Observable; retry(retryCount?: number): Observable; - scan(accumulator: (acc: TAcc, value: T, seed: TAcc) => TAcc): Observable; - scan(accumulator: (acc: T, value: T) => T): Observable; + + /** + * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. + * For aggregation behavior with no intermediate results, see Observable.aggregate. + * @example + * var res = source.scan(function (acc, x) { return acc + x; }); + * var res = source.scan(function (acc, x) { return acc + x; }, 0); + * @param accumulator An accumulator function to be invoked on each element. + * @param seed The initial accumulator value. + * @returns An observable sequence containing the accumulated values. + */ + scan(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable) => TAcc, seed: TAcc): Observable; + scan(accumulator: (acc: T, value: T, index?: number, source?: Observable) => T): Observable; + skipLast(count: number): Observable; startWith(...values: T[]): Observable; startWith(scheduler: IScheduler, ...values: T[]): Observable;