This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/htmlparser2/lib/WritableStream.js
2019-08-11 20:48:02 +02:00

25 lines
730 B
JavaScript

module.exports = Stream;
var Parser = require("./Parser.js");
var WritableStream = require("readable-stream").Writable;
var StringDecoder = require("string_decoder").StringDecoder;
var Buffer = require("buffer").Buffer;
function Stream(cbs, options) {
var parser = (this._parser = new Parser(cbs, options));
var decoder = (this._decoder = new StringDecoder());
WritableStream.call(this, { decodeStrings: false });
this.once("finish", function() {
parser.end(decoder.end());
});
}
require("inherits")(Stream, WritableStream);
Stream.prototype._write = function(chunk, encoding, cb) {
if (chunk instanceof Buffer) chunk = this._decoder.write(chunk);
this._parser.write(chunk);
cb();
};