feat(lib/utils/proxy): store targets
This commit is contained in:
parent
db52252c68
commit
400026daec
2 changed files with 6 additions and 6 deletions
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
export const _instances = new WeakSet<object>()
|
||||
// export const _targets = new WeakMap<object, object>()
|
||||
export const _targets = new WeakMap<object, object>()
|
||||
|
||||
const OriginalProxy = globalThis.Proxy
|
||||
globalThis.Proxy = new Proxy(OriginalProxy, {
|
||||
|
|
@ -12,7 +12,7 @@ globalThis.Proxy = new Proxy(OriginalProxy, {
|
|||
// @ts-expect-error
|
||||
const prox = new OriginalProxy(...args)
|
||||
_instances.add(prox)
|
||||
// _targets.set(prox, args[0])
|
||||
_targets.set(prox, args[0])
|
||||
return prox
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { _instances /* _targets */ } from '../../init/src/patches/proxy'
|
||||
import { _instances, _targets } from '../../init/src/patches/proxy'
|
||||
|
||||
/**
|
||||
* Returns whether the object is a proxy
|
||||
|
|
@ -8,6 +8,6 @@ export function isProxy(obj: object) {
|
|||
return _instances.has(obj)
|
||||
}
|
||||
|
||||
// export function getProxyTarget(obj: object) {
|
||||
// return _targets.get(obj)
|
||||
// }
|
||||
export function getProxyTarget(obj: object) {
|
||||
return _targets.get(obj)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue