This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delegateTo(prop: string) { | |
const { __proto__ } = this | |
Object.setPrototypeOf(this, | |
new Proxy({}, { | |
get: (target, name) => { | |
target = this[prop] | |
if (name === prop) return target | |
if (name in __proto__) return __proto__[name] | |
return target ? target[name] : undefined |