We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 34ef9c9 commit c503635Copy full SHA for c503635
src/0-core/measure/cache.js
@@ -1,5 +1,12 @@
1
import {CachedMeasure} from './index.js';
2
3
+const CACHE = new WeakMap();
4
+
5
export function cache(M) {
- return M instanceof CachedMeasure ? M : new CachedMeasure(M);
6
+ if (CACHE.has(M)) return CACHE.get(M);
7
8
+ const cM = new CachedMeasure(M);
9
+ CACHE.set(M, cM);
10
+ CACHE.set(cM, cM);
11
+ return cM;
12
}
0 commit comments