proxied
创建动态代理对象
75 bytes
since v12.1.0
使用方法
JavaScript 的 Proxy 对象很强大,但使用起来有点笨拙。_.proxied 函数为您创建 Proxy 并处理当 Proxy 上的函数被调用或属性被访问时回调到您的处理程序。
import * as_ from 'radashi'
type Property = 'name' | 'size' | 'getLocation'
const person = _.proxied((prop: Property) => { switch (prop) { case 'name': return 'Joe' case 'size': return 20 case 'getLocation' return () => 'here' }})
person.name // => Joeperson.size // => 20person.getLocation() // => here