@actualwave/with-proxy 中文文档教程
withProxy
用于使用 Proxy 包装对象的工厂生成器。 将 construct
和 apply
陷阱应用于函数目标。
const myFactory = withProxy({
get: myGetHandler,
set: mySetHandler,
apply: myApplyHandler,
construct: myConstructHandler,
});
const myWrappedFunction = myFactory(() => null); // gets all traps
const myWrappedObject = myFactory({}); // does not get "apply" and "construct" traps
withProxy
Factory generator for wrapping objects with Proxy. Applies construct
and apply
traps to function targets.
const myFactory = withProxy({
get: myGetHandler,
set: mySetHandler,
apply: myApplyHandler,
construct: myConstructHandler,
});
const myWrappedFunction = myFactory(() => null); // gets all traps
const myWrappedObject = myFactory({}); // does not get "apply" and "construct" traps