-
Notifications
You must be signed in to change notification settings - Fork 0
API Proxy
Liu.Yandong.Hanks edited this page Aug 19, 2026
·
3 revisions
动态对象访问拦截
Dynamic object-access interception
Proxy 包装一个目标对象,并将属性读取和写入交给处理器。选项对象必须提供 get 和 set;处理器应保持明确、无递归副作用,以避免难以追踪的行为。
Proxywraps a target object and delegates property reads and writes to handlers. The options object must providegetandset; handlers should be explicit and free of recursive side effects.
Parameters:
-
target
被包装的对象。Object to wrap.
-
options
包含get(obj, key)和set(obj, key, value)的对象。Object containing
get(obj, key)andset(obj, key, value).
Returns
Proxy 对象。
A
Proxyobject.
var source = { count: 1 };
var proxy = new Proxy(source, {
get: (obj, key) => obj[key],
set: (obj, key, value) => { obj[key] = value; return value; }
});
proxy.count = 2;
return proxy.count; // 2边界行为
缺少 get 或 set 是无效构造;不要在处理器内无条件再次读取或写入同一 Proxy。
Missing
getorsetis invalid; do not unconditionally re-read or re-write the same proxy from a handler.
AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License