mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-27 14:30:49 +08:00
[Ramda] Improved memoize definition (#25596)
* Ramda: improved memoize definition * Ramda: improved memoize definition (fixed test)
This commit is contained in:
committed by
Sheetal Nandi
parent
31f0a91829
commit
5a46131513
4
types/ramda/index.d.ts
vendored
4
types/ramda/index.d.ts
vendored
@@ -1021,11 +1021,13 @@ declare namespace R {
|
||||
median(list: ReadonlyArray<number>): number;
|
||||
|
||||
/**
|
||||
* @deprecated since v0.25.0
|
||||
*
|
||||
* Creates a new function that, when invoked, caches the result of calling fn for a given argument set and
|
||||
* returns the result. Subsequent calls to the memoized fn with the same argument set will not result in an
|
||||
* additional call to fn; instead, the cached result for that set of arguments will be returned.
|
||||
*/
|
||||
memoize<T = any>(fn: (...a: any[]) => T): (...a: any[]) => T;
|
||||
memoize<T extends (...args: any[]) => any>(fn: T): T;
|
||||
|
||||
/**
|
||||
* A customisable version of R.memoize. memoizeWith takes an additional function that will be applied to a given
|
||||
|
||||
@@ -305,7 +305,7 @@ R.times(i, 5);
|
||||
function stringLength(str: string): number {
|
||||
return str.length;
|
||||
}
|
||||
const memoStringLength = R.memoize<number>(stringLength);
|
||||
const memoStringLength = R.memoize(stringLength);
|
||||
const isLong = memoStringLength('short') > 10; // false
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user