@bothrs/util
Advanced tools
Comparing version 2.0.0 to 2.0.1
13
memo.ts
@@ -8,6 +8,3 @@ /** | ||
*/ | ||
export function memo<T extends (...args: any[]) => any>( | ||
func: T, | ||
timeout = 0 | ||
): (...args: Parameters<T>) => ReturnType<T> { | ||
export function memo<T extends (...args: any[]) => any>(func: T, timeout = 0) { | ||
const cache: { [key: string]: ReturnType<T> | null } = {} | ||
@@ -29,4 +26,4 @@ const f = function (...[a, b, c]: Parameters<T>): ReturnType<T> { | ||
(cache[JSON.stringify(key)] = value) | ||
// @ts-ignore | ||
f.reset = (a, b, c) => (cache[JSON.stringify([a, b, c])] = null) | ||
f.reset = (...[a, b, c]: Parameters<T>) => | ||
(cache[JSON.stringify([a, b, c])] = null) | ||
return f | ||
@@ -68,5 +65,5 @@ } | ||
(cache[JSON.stringify([a, b, c])] = value) | ||
// @ts-ignore | ||
f.reset = (a, b, c) => (cache[JSON.stringify([a, b, c])] = null) | ||
f.reset = (...[a, b, c]: Parameters<T>) => | ||
(cache[JSON.stringify([a, b, c])] = null) | ||
return f | ||
} |
{ | ||
"name": "@bothrs/util", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Common helper functions", | ||
@@ -17,10 +17,9 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^13.11.1", | ||
"@types/node-fetch": "^2.5.4", | ||
"node-fetch": "^2.6.0", | ||
"@types/node": "14", | ||
"@types/node-fetch": "2", | ||
"node-fetch": "^2.6.1", | ||
"prettier": "2", | ||
"rollup-plugin-multi-entry": "^2.1.0", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.7.4" | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"typescript": "4" | ||
}, | ||
@@ -27,0 +26,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
68307
2256