blob: aaecb9cc8ff7ca447dde26a59276d6b9628342bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
let c = 0;
function f1() {
c++;
}
function LoggingProxyHandlerWrapper(name, handler={}) {
return new Proxy(handler, {
get(x, id) {
return function (...args) {
return Reflect[id].apply(null, args);
};
}
});
}
function LoggingProxy(name, target) {
return new Proxy(f1, new LoggingProxyHandlerWrapper(name));
}
function test() {
let proxy = new LoggingProxy("proto", {});
for (let i = 0; i < 2000; i++) {
new proxy();
}
assertEq(c, 2000);
}
test();
|