@bitcoinerlab/discovery
Version:
A TypeScript library for retrieving Bitcoin funds from ranged descriptors, leveraging @bitcoinerlab/explorer for standardized access to multiple blockchain explorers.
22 lines (21 loc) • 1.09 kB
TypeScript
/**
* This function is an extension of memoizee which stores the result of the
* latest call (cache size one). It is designed to work with functions that
* return arrays. If the arguments for the current call are the same as the
* latest call, it will return the same result. If the arguments are different,
* but the returned array is shallowly equal to the previous one, it still
* returns the same object.
*
* @param {Function} func - The function to be memoized. Must return an array.
* @returns {Function} A memoized version of the input function. Returns an array.
*
* @example
* const memoizedFunc = memoizeOneWithShallowArraysCheck(myFunc);
* const result1 = memoizedFunc(arg1, arg2);
* const result2 = memoizedFunc(arg1, arg2);
* // Will return the same object as result1
* const result3 = memoizedFunc(arg3, arg4);
* // If the result is shallowly equal to result1, it will still return the
* // same object as result1
*/
export declare function memoizeOneWithShallowArraysCheck<T extends unknown[], R extends unknown[]>(func: (...args: T) => R): (...args: T) => R;