aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/scripts/class-definitions.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-17 19:26:10 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-17 19:26:10 -0700
commitc720bdc324e40385676b0d465ae9df8bfc4ec37b (patch)
tree3da42427c5f51ff737106155eff76360f34a81ec /src/bun.js/scripts/class-definitions.ts
parentbc412e1f6fb4057b25981772b48c1f7d228fcebb (diff)
downloadbun-c720bdc324e40385676b0d465ae9df8bfc4ec37b.tar.gz
bun-c720bdc324e40385676b0d465ae9df8bfc4ec37b.tar.zst
bun-c720bdc324e40385676b0d465ae9df8bfc4ec37b.zip
Move around some things
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))
+ ),
+ };
+}