Skip to content

Commit

Permalink
drop split and stream-combiner to make the default stream not drop ne…
Browse files Browse the repository at this point in the history
…wlines in ie<9
  • Loading branch information
James Halliday committed Dec 17, 2013
1 parent 9b8a771 commit ea56255
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 15 additions & 5 deletions lib/default_stream.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
var through = require('through');
var combine = require('stream-combiner');
var split = require('split');

module.exports = function () {
var stream = combine(split(), through(write));
return stream;
var line = '';
return through(write, flush);

function write (line) {
function write (buf) {
for (var i = 0; i < buf.length; i++) {
var c = typeof buf === 'string'
? buf.charAt(i)
: String.fromCharCode(buf[i])
;
if (c === '\n') flush();
else line += c;
}
}

function flush () {
try { console.log(line); }
catch (e) { stream.emit('error', e) }
line = '';
}
};
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"defined" : "~0.0.0",
"through": "~2.3.4",
"resumer": "~0.0.0",
"stream-combiner": "~0.0.2",
"split": "~0.2.10",
"inherits": "~2.0.1"
},
"devDependencies" : {
Expand Down

0 comments on commit ea56255

Please sign in to comment.