/
node-expat.js
38 lines (33 loc) · 990 Bytes
/
node-expat.js
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
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var expat = require('../build/default/node-expat');
/**
* Simple wrapper because EventEmitter has turned pure-JS as of node
* 0.5.x.
*/
exports.Parser = function(encoding) {
this.parser = new expat.Parser(encoding);
var that = this;
this.parser.emit = function() {
that.emit.apply(that, arguments);
};
};
util.inherits(exports.Parser, EventEmitter);
exports.Parser.prototype.parse = function(buf, isFinal) {
return this.parser.parse(buf, isFinal);
};
exports.Parser.prototype.setEncoding = function(encoding) {
return this.parser.setEncoding(encoding);
};
exports.Parser.prototype.getError = function() {
return this.parser.getError();
};
exports.Parser.prototype.stop = function() {
return this.parser.stop();
};
exports.Parser.prototype.pause = function() {
return this.stop();
};
exports.Parser.prototype.resume = function() {
return this.parser.resume();
};