-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
59 lines (50 loc) · 2.38 KB
/
index.d.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export default function InitXMLObjectStream(config?: Config): XMLObjectStream;
interface Config {
/**
* Whether to enable strict parsing in the underlying sax parser.
* @default true
*/
strict?: boolean;
/**
* Whether to use a case-insensitive match when looking for elements. Non-strict will enable this by default.
* @default false
*/
icase?: boolean;
/**
* Whether to return a JS object tree for matches that has attributes and children set as keys. Duplicate keys will result in an array of values, and children with no further children will have their text content as their value. If children don't only contain text, the text is available as the `text` property.
* @default false
*/
pojo?: boolean;
/**
* The chunk size to use when processing the xml. If callbacks are used, this affects how often the parser will yield computation control to allow the callbacks to process.
* @default 8194
*/
chunkSize?: number;
}
/** Any old object that says it can pipe to a writeable stream. */
interface Pipeable {
pipe(stream: NodeJS.WritableStream): void;
}
interface Done {
onEnd(callback: () => void): void;
}
/**
* Parses the given xml looking for nodes that match the given pattern, collecting them into an array to be returned once the xml has been fully parsed.
* @param xml the xml to process
* @param pattern the xpath-like query used to match nodes
*/
function XMLObjectStream(xml: string|Pipeable, pattern: string): Promise<any[]>;
/**
* Parses the given xml looking for nodes that match the given pattern. As each node matches, the callback will be called with the match.
* @param xml the xml to process
* @param pattern the xpath-like query used to match nodes
* @param callback the callback function to be called with matches
*/
function XMLObjectStream(xml: string|Pipeable, pattern: string, callback: (match: any) => void): Done;
/**
* Parses the given xml looking for nodes that match the given pattern. As each node matches, the callback will be called with the match, and processing will be suspended until the callback calls resume.
* @param xml the xml to process
* @param pattern the xpath-like query used to match nodes
* @param callback the callback function to be called with matches and a resumption function
*/
function XMLObjectStream(xml: string|Pipeable, pattern: string, callback: (match: any, resume: () => void) => Done): void;