moderndash
Advanced tools
Comparing version 0.12.3 to 0.12.4
@@ -323,12 +323,12 @@ /** | ||
type GenericFunction<TFunc extends (...args: any) => void> = (...args: Parameters<TFunc>) => ReturnType<TFunc>; | ||
type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>; | ||
/** | ||
* Creates a function that memoizes the result of `func`. | ||
* The cache key is either determined by the provided resolver or by the arguments used in the memoized function. | ||
* Creates a function that caches the result of `func`. | ||
* | ||
* The cache is exposed as the `cache` property on the memoized function. | ||
* Its creation may be customized by replacing the `memoize.cache` value. | ||
* The new cache must implement `get` and `set` methods like the built-in `Map` constructors. | ||
* The cache key is either determined by the provided `resolver` or by the arguments used in the cached function. | ||
* | ||
* The `cache` property is exposed on the cached function. It is an instance of `Map` and can be used to clear or inspect the cache. | ||
* The cache property can be replaced by a custom cache as long as it implements the `Map` interface. | ||
* | ||
* **Options:** | ||
@@ -354,8 +354,6 @@ * - `resolver` A function that determines the cache key for storing the result based on the arguments provided. | ||
* | ||
* // Replace `memoize.cache`. | ||
* values.cache = new WeakMap() | ||
* | ||
* // Cached values are exposed as the `cache` property. | ||
* values.cache.get(object) | ||
* values.cache.set(object, ['a', 'b']) | ||
* values.cache.clear() | ||
* | ||
@@ -371,4 +369,4 @@ * // This is the default way to create cache keys. | ||
*/ | ||
declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string | symbol, [ReturnType<TFunc>, number]>>(func: TFunc, options?: { | ||
resolver?: (...args: Parameters<TFunc>) => string | symbol; | ||
declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map<string, [ReturnType<TFunc>, number]>>(func: TFunc, options?: { | ||
resolver?: (...args: Parameters<TFunc>) => string; | ||
ttl?: number; | ||
@@ -375,0 +373,0 @@ }): TFunc & { |
@@ -293,3 +293,3 @@ // src/array/chunk.ts | ||
// src/decorator/decMemonize.ts | ||
// src/decorator/decMemoize.ts | ||
function decMemoize(options = {}) { | ||
@@ -296,0 +296,0 @@ return toDecorator(memoize)(options); |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "0.12.3" | ||
"version": "0.12.4" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
211978
2398