summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js')
-rw-r--r--bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js b/bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js
new file mode 100644
index 00000000..ac45b49f
--- /dev/null
+++ b/bin/wiki/ImportarDesdeURL/node_modules/htmlparser2/lib/WritableStream.js
@@ -0,0 +1,25 @@
+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();
+};