forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sax.d.ts
78 lines (68 loc) · 2.22 KB
/
sax.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Type definitions for sax js
// Project: https://github.com/isaacs/sax-js
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "sax" {
export var EVENTS: string[];
interface SAXOptions {
trim?: boolean;
normalize?: boolean;
lowercase?: boolean;
xmlns?: boolean;
noscript?: boolean;
position?: boolean;
}
export interface Tag {
name: string;
attributes: { [key: string]: string };
// Available if opt.xmlns
ns?: { [key: string]: string };
prefix?: string;
local?: string;
uri?: string;
}
export function parser(strict: boolean, opt: SAXOptions): SAXParser;
export class SAXParser {
constructor(strict: boolean, opt: SAXOptions);
// Methods
end(): void;
write(s: string): SAXParser;
resume(): SAXParser;
close(): SAXParser;
flush(): void;
// Members
line: number;
column: number;
error: Error;
position: number;
startTagPosition: number;
closed: boolean;
strict: boolean;
opt: SAXOptions;
tag: string;
// Events
onerror(e: Error): void;
ontext(t: string): void;
ondoctype(doctype: string): void;
onprocessinginstruction(node: { name: string; body: string }): void;
onopentag(tag: Tag): void;
onclosetag(tagName: string): void;
onattribute(attr: { name: string; value: string }): void;
oncomment(comment: string): void;
onopencdata(): void;
oncdata(cdata: string): void;
onclosecdata(): void;
onopennamespace(ns: { prefix: string; uri: string }): void;
onclosenamespace(ns: { prefix: string; uri: string }): void;
onend(): void;
onready(): void;
onscript(script: string): void;
}
import stream = require("stream");
export function createStream(strict: boolean, opt: SAXOptions): SAXStream;
export class SAXStream extends stream.Duplex {
constructor(strict: boolean, opt: SAXOptions);
private _parser: SAXParser;
}
}