aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/scripts/class-definitions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/scripts/class-definitions.ts')
-rw-r--r--src/bun.js/scripts/class-definitions.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/bun.js/scripts/class-definitions.ts b/src/bun.js/scripts/class-definitions.ts
new file mode 100644
index 000000000..4b202f8a5
--- /dev/null
+++ b/src/bun.js/scripts/class-definitions.ts
@@ -0,0 +1,36 @@
+export type Field =
+ | { getter: string; cache?: true }
+ | { setter: string }
+ | { accessor: { getter: string; setter: string }; cache?: true }
+ | {
+ fn: string;
+ length?: number;
+ DOMJIT?: {
+ return: string;
+ args?: [string, string] | [string, string, string] | [string];
+ symbol: string;
+ };
+ };
+
+export interface ClassDefinition {
+ name: string;
+ construct?: boolean;
+ finalize?: boolean;
+ klass: Record<string, Field>;
+ proto: Record<string, Field>;
+ JSType?: string;
+}
+
+export function define(
+ { klass = {}, proto = {}, ...rest } = {} as ClassDefinition
+): ClassDefinition {
+ return {
+ ...rest,
+ klass: Object.fromEntries(
+ Object.entries(klass).sort(([a], [b]) => a.localeCompare(b))
+ ),
+ proto: Object.fromEntries(
+ Object.entries(proto).sort(([a], [b]) => a.localeCompare(b))
+ ),
+ };
+}