UNPKG

1.77 kBTypeScriptView Raw
1export interface IText {
2 nodeValue: string | null;
3}
4export interface IElement {
5 readonly tagName: string;
6 childNodes: {
7 length: number;
8 [index: number]: IElement | IText;
9 };
10 toString: () => string;
11}
12/**
13 * Decode an XML string.
14 *
15 * @param xml XML string.
16 * @returns Decoded declaration, doctype, and document element.
17 */
18export declare function xmlDecode(xml: string): {
19 declaration: string | null;
20 doctype: string | null;
21 documentElement: Readonly<IElement>;
22};
23/**
24 * List XML element child elements.
25 * Throws if non-whitespace nodes are found.
26 *
27 * @param element XML element.
28 * @returns XML element list.
29 */
30export declare function xmlElementChildElements<T extends Readonly<IElement>>(element: T): T[];
31/**
32 * Get the XML element text node.
33 * Returns null if none, throws if multiple elements.
34 *
35 * @param element XML element.
36 * @returns XML text node list.
37 */
38export declare function xmlElementText(element: Readonly<IElement>): IText | null;
39/**
40 * Assert XML element has no children.
41 *
42 * @param element XML element.
43 * @param tagName XML element tag name.
44 */
45export declare function assertXmlTagName(element: Readonly<IElement>, tagName: string): void;
46/**
47 * Assert XML element has no children.
48 *
49 * @param element XML element.
50 */
51export declare function assertNoXmlElementChildNodes(element: Readonly<IElement>): void;
52/**
53 * Base64 encode function mirroring decode function.
54 *
55 * @param data Byte array.
56 * @returns Base64 string.
57 */
58export declare function base64Encode(data: Uint8Array): string;
59/**
60 * Base64 decode function that matches plist parsing behavior.
61 *
62 * @param base64 Base64 string.
63 * @returns Byte array.
64 */
65export declare function base64Decode(base64: string): Uint8Array;