@politie/sherlock-utils
Version:
Utility functions that are designed to work with Sherlock. His toolbelt.
18 lines (17 loc) • 950 B
TypeScript
/**
* Calls the provided dyadic function with respectively the current and previous value that was received by the returned monadic function.
* In other words, when you wrap a function with wrapPreviousState you not only get the current value, but also the previous one (as a
* second parameter).
*
* @param f the function to wrap
*/
export declare function pairwise<V, R>(f: (newValue: V, oldValue?: V) => R): (value: V) => R;
/**
* Calls the provided dyadic function with respectively the current and previous value that was received by the returned monadic function.
* In other words, when you wrap a function with wrapPreviousState you not only get the current value, but also the previous one (as a
* second parameter).
*
* @param f the function to wrap
* @param init the value to use the first time as second argument to `f`.
*/
export declare function pairwise<V, R>(f: (newValue: V, oldValue: V) => R, init: V): (value: V) => R;