Comparing version 0.3.4 to 0.3.5
38
index.js
@@ -15,4 +15,18 @@ var sax = require('sax'); | ||
var parser = sax.parser(false); | ||
var stream = select(parser, opts); | ||
var stream = select(parser, opts, write, end); | ||
function write (buf) { | ||
var s = buf.toString(); | ||
buffered += s; | ||
parser.write(buf.toString()); | ||
} | ||
function end () { | ||
if (pos < parser.position) { | ||
var s = buffered.slice(0, parser.position - pos); | ||
stream.raw(s); | ||
} | ||
this.queue(null); | ||
} | ||
parser.onerror = function (err) { | ||
@@ -22,6 +36,2 @@ stream.emit("error", err) | ||
function write (buf) { | ||
stream.emit('data', buf); | ||
} | ||
var buffered = ''; | ||
@@ -73,18 +83,2 @@ var pos = 0; | ||
stream.write = function (buf) { | ||
var s = buf.toString(); | ||
buffered += s; | ||
parser.write(buf.toString()); | ||
}; | ||
stream.end = function (buf) { | ||
if (buf !== undefined) stream.write(buf); | ||
if (pos < parser.position) { | ||
var s = buffered.slice(0, parser.position - pos); | ||
stream.raw(s); | ||
} | ||
stream.emit('end'); | ||
}; | ||
var lastOpen; | ||
@@ -91,0 +85,0 @@ parser.onopentag = function (tag) { |
@@ -1,6 +0,6 @@ | ||
var Stream = require('stream').Stream; | ||
var through = require('through'); | ||
var createNode = require('./node'); | ||
module.exports = function (parser, opts) { | ||
var stream = new Stream; | ||
module.exports = function (parser, opts, write, end) { | ||
var stream = through(write, end); | ||
stream.parser = parser; | ||
@@ -7,0 +7,0 @@ stream.writable = true; |
{ | ||
"name" : "trumpet", | ||
"version" : "0.3.4", | ||
"version" : "0.3.5", | ||
"description" : "parse and transform streaming html using css selectors", | ||
@@ -13,6 +13,7 @@ "main" : "index.js", | ||
"sax" : "~0.3.5", | ||
"ent" : "~0.0.4" | ||
"ent" : "~0.0.4", | ||
"through": "~2.3.4" | ||
}, | ||
"devDependencies" : { | ||
"tap" : "~0.2.3" | ||
"tap" : "~0.4.0" | ||
}, | ||
@@ -19,0 +20,0 @@ "scripts" : { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36715
3
790
+ Addedthrough@~2.3.4
+ Addedthrough@2.3.8(transitive)