-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdescribe.ts
32 lines (30 loc) · 1.06 KB
/
describe.ts
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
import { Private, PrivateDescription } from "./describe/Private.js";
import { Text, TextDescription } from "./describe/Text.js";
import { EnumType, EnumTypeDescription } from "./describe/EnumType.js";
import { DAType, DATypeDescription } from "./describe/DAType.js";
import { DOType, DOTypeDescription } from "./describe/DOType.js";
import { LNodeType, LNodeTypeDescription } from "./describe/LNodeType.js";
import { LN, LNDescription } from "./describe/LN.js";
export type Description =
| PrivateDescription
// eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
| TextDescription // FIXME: duplication to PrivateDescription
| EnumTypeDescription
| DATypeDescription
| DOTypeDescription
| LNodeTypeDescription
| LNDescription;
const sclElementDescriptors: Partial<
Record<string, (element: Element) => Description | undefined>
> = {
Private,
Text,
EnumType,
DAType,
DOType,
LNodeType,
LN,
};
export function describe(element: Element): Description | undefined {
return sclElementDescriptors[element.tagName]?.(element);
}