From c720bdc324e40385676b0d465ae9df8bfc4ec37b Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 17 Aug 2022 19:26:10 -0700 Subject: Move around some things --- src/bun.js/scripts/class-definitions.ts | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/bun.js/scripts/class-definitions.ts (limited to 'src/bun.js/scripts/class-definitions.ts') 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; + proto: Record; + 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)) + ), + }; +} -- cgit v1.2.3