@bodar/totallylazy
Advanced tools
Comparing version 0.423.266 to 0.424.267
11
cache.js
@@ -7,5 +7,14 @@ "use strict"; | ||
throw new Error("@cache can only decorate methods"); | ||
const cache = new Map(); | ||
const cacheMap = new WeakMap(); | ||
function getCache(key) { | ||
const cache = cacheMap.get(key); | ||
if (cache) | ||
return cache; | ||
const map = new Map(); | ||
cacheMap.set(key, map); | ||
return map; | ||
} | ||
return Object.defineProperty(target, name, Object.assign(Object.assign({}, descriptor), { value: function (...args) { | ||
const key = JSON.stringify(args); | ||
const cache = getCache(this); | ||
const result = cache.get(key); | ||
@@ -12,0 +21,0 @@ if (typeof result !== 'undefined') |
{ | ||
"name": "@bodar/totallylazy", | ||
"version": "0.423.266", | ||
"version": "0.424.267", | ||
"description": "Totallylazy", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:bodar/totallylazy.js.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
430300
6276