char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somport web extension to typescript44fe2c6

main
781 B28 linesraw
1import {
2  ObjectDefineProperty as define,
3  ObjectGetOwnPropertyDescriptor as descriptor,
4  ReflectOwnKeys,
5  SymbolToStringTag,
6} from "ext:core/primordials";
7
8export function installGlobal(name: string, value: unknown): void {
9  define(globalThis, name, { value, writable: true, configurable: true });
10}
11export function installInterface(
12  name: string,
13  ctor: { prototype: object },
14): void {
15  const keys = ReflectOwnKeys(ctor.prototype);
16  for (let i = 0; i < keys.length; i++) {
17    if (keys[i] !== "constructor") {
18      const d = descriptor(ctor.prototype, keys[i])!;
19      d.enumerable = true;
20      define(ctor.prototype, keys[i], d);
21    }
22  }
23  define(ctor.prototype, SymbolToStringTag, {
24    value: name,
25    configurable: true,
26  });
27  installGlobal(name, ctor);
28}