Skip to content

Commit bdbee85

Browse files
committed
Create a new cache per this
1 parent 65c4945 commit bdbee85

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/index.mjs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
import { MINI } from './constants.mjs';
1515
import { build, evaluate } from './build.mjs';
1616

17-
const regular = h => {
18-
const cache = new Map();
17+
const CACHES = new Map();
1918

20-
return function(statics) {
21-
let tmp = cache.get(statics);
22-
if (!tmp) {
23-
cache.set(statics, tmp = build(statics));
24-
}
25-
tmp = evaluate(h, tmp, arguments, []);
26-
return tmp.length > 1 ? tmp : tmp[0];
27-
};
19+
const regular = function(statics) {
20+
let tmp = CACHES.get(this);
21+
if (!tmp) {
22+
tmp = new Map();
23+
CACHES.set(this, tmp);
24+
}
25+
tmp = evaluate(this, tmp.get(statics) || (tmp.set(statics, tmp = build(statics)), tmp), arguments, []);
26+
return tmp.length > 1 ? tmp : tmp[0];
2827
};
2928

30-
export default MINI ? build : { bind: regular };
29+
export default MINI ? build : regular;

0 commit comments

Comments
 (0)