import { ObjectDefineProperty as define, ObjectGetOwnPropertyDescriptor as descriptor, ReflectOwnKeys, SymbolToStringTag, } from "ext:core/primordials"; export function installGlobal(name: string, value: unknown): void { define(globalThis, name, { value, writable: true, configurable: true }); } export function installInterface( name: string, ctor: { prototype: object }, ): void { const keys = ReflectOwnKeys(ctor.prototype); for (let i = 0; i < keys.length; i++) { if (keys[i] !== "constructor") { const d = descriptor(ctor.prototype, keys[i])!; d.enumerable = true; define(ctor.prototype, keys[i], d); } } define(ctor.prototype, SymbolToStringTag, { value: name, configurable: true, }); installGlobal(name, ctor); }