UNPKG

@politie/sherlock-utils

Version:

Utility functions that are designed to work with Sherlock. His toolbelt.

20 lines (19 loc) 1.25 kB
/** * Converts an accumulator function into a monadic function. On each call to the returned monadic function, the accumulator function is * called with the value that was passed to the monadic function and the result of the last invocation of the accumulator function. It * works similar to {@link Array#reduce}, but returns each intermediate result. If the seed is specified, then that value will be used * as the initial value for the accumulator. * * @param f the function to wrap */ export declare function scan<V, R>(f: (acc: R | undefined, value: V) => R): (value: V) => R; /** * Converts an accumulator function into a monadic function. On each call to the returned monadic function, the accumulator function is * called with the value that was passed to the monadic function and the result of the last invocation of the accumulator function. It * works similar to {@link Array#reduce}, but returns each intermediate result. If the seed is specified, then that value will be used * as the initial value for the accumulator. * * @param f the function to wrap * @param seed the value to use the first time as second argument to `f`. */ export declare function scan<V, R>(f: (acc: R, value: V) => R, seed: R): (value: V) => R;