aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-14 22:38:36 +0200
committerVendicated <vendicated@riseup.net>2022-10-14 22:40:16 +0200
commita4e98f92520306dad8bb1cdd9884f0b331fd0bdd (patch)
treeb2aa063ebd88e43ba893a90370ed0f8315d50b6b /src
parent53794ec180daad2c7de8eac0db03a351527b227c (diff)
downloadVencord-a4e98f92520306dad8bb1cdd9884f0b331fd0bdd.tar.gz
Vencord-a4e98f92520306dad8bb1cdd9884f0b331fd0bdd.tar.bz2
Vencord-a4e98f92520306dad8bb1cdd9884f0b331fd0bdd.zip
proxyLazy: Fix constructors
Diffstat (limited to 'src')
-rw-r--r--src/utils/proxyLazy.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/utils/proxyLazy.ts b/src/utils/proxyLazy.ts
index 6aa04bf..a5c0835 100644
--- a/src/utils/proxyLazy.ts
+++ b/src/utils/proxyLazy.ts
@@ -1,5 +1,7 @@
import { makeLazy } from "./misc";
+const ProxyDummy = function () { };
+
/**
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
* On first property access, the lazy is evaluated
@@ -12,14 +14,15 @@ import { makeLazy } from "./misc";
export function proxyLazy<T>(factory: () => T): T {
const lazy = makeLazy(factory);
- return new Proxy(() => null, {
+ return new Proxy(ProxyDummy, {
get: (_, prop) => lazy()[prop],
set: (_, prop, value) => lazy()[prop] = value,
has: (_, prop) => prop in lazy(),
apply: (_, $this, args) => (lazy() as Function).apply($this, args),
ownKeys: () => Reflect.ownKeys(lazy() as object),
- construct: (_, args, newTarget) => Reflect.construct(lazy() as Function, args, newTarget),
+ construct: (_, args) => Reflect.construct(lazy() as Function, args),
deleteProperty: (_, prop) => delete lazy()[prop],
- defineProperty: (_, property, attributes) => !!Object.defineProperty(lazy(), property, attributes)
+ defineProperty: (_, property, attributes) => !!Object.defineProperty(lazy(), property, attributes),
+ getPrototypeOf: () => Object.getPrototypeOf(lazy())
}) as any as T;
}