blob: e7cc9338501580eac439e23c172ef81d7aeea418 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
var access_log = "";
const handler = {
get: function(obj, prop) {
access_log += prop + ",";
return prop in obj ? obj[prop] : "<filled by proxy>";
}
};
class ProxiedGroupRegExp extends RegExp {
exec(s) {
var result = super.exec(s);
if (result) {
result.groups = new Proxy(result.groups, handler);
}
return result;
}
}
let re = new ProxiedGroupRegExp("(?<x>.)");
assertEq("a".replace(re, "$<x> $<y>"), "a <filled by proxy>");
assertEq(access_log, "x,y,")
|