-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproxy.js
More file actions
35 lines (35 loc) · 905 Bytes
/
proxy.js
File metadata and controls
35 lines (35 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var Overload=require("./overload");
var Watchable=Overload.Watchable;
var RePrototype=Overload.RePrototype;
module.exports = {
create: function(handler,prototype) {
var proxy=Watchable(
//get
function(ArgInfo) {
return handler["get"].call(ArgInfo.thisObject,ArgInfo.holder,ArgInfo.property)
}
//set
,function(context) {
return handler["set"].call(context.thisObject,context.holder,context.property,context.value)
}
//enum
,function(context) {
return handler["enumerate"].call(context.thisObject);
}
//query
,function(context) {
return !!handler["has"].call(context.thisObject,context.property);
}
//delete
,function(context) {
return !!handler["delete"].call(context.thisObject,context.property);
}
//call
,null
//construct
,null
);
RePrototype(proxy,prototype||Object.getPrototypeOf(new Object()));
return proxy;
}
}