blob: 67e4cf4750096e2974695734347c623f310ee2a7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
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;
noConstructor?: boolean;
}
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))
),
};
}
|