Comparing version 9.0.0 to 9.0.1
import mimicFn from 'mimic-fn'; | ||
import mapAgeCleaner from 'map-age-cleaner'; | ||
const decoratorInstanceMap = new WeakMap(); | ||
const cacheStore = new WeakMap(); | ||
@@ -83,2 +82,3 @@ /** | ||
export function memDecorator(options = {}) { | ||
const instanceMap = new WeakMap(); | ||
return (target, propertyKey, descriptor) => { | ||
@@ -92,8 +92,8 @@ const input = target[propertyKey]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
descriptor.get = function () { | ||
if (!decoratorInstanceMap.has(this)) { | ||
if (!instanceMap.has(this)) { | ||
const value = mem(input, options); | ||
decoratorInstanceMap.set(this, value); | ||
instanceMap.set(this, value); | ||
return value; | ||
} | ||
return decoratorInstanceMap.get(this); | ||
return instanceMap.get(this); | ||
}; | ||
@@ -100,0 +100,0 @@ }; |
{ | ||
"name": "mem", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
17535