Comparing version 0.1.6 to 0.1.7
var util = require('util'), | ||
events = require('events'); | ||
function Carrier(reader, listener, encoding) { | ||
function Carrier(reader, listener, encoding, separator) { | ||
var self = this; | ||
@@ -9,2 +9,6 @@ | ||
if (!separator) { | ||
separator = /\r?\n/; | ||
} | ||
if (listener) { | ||
@@ -16,9 +20,8 @@ self.addListener('line', listener); | ||
reader.setEncoding(encoding || 'utf-8'); | ||
reader.setEncoding(encoding || 'utf8'); | ||
reader.on('data', function(data) { | ||
var lines = (buffer + data).split("\n"); | ||
var lines = (buffer + data).split(separator); | ||
buffer = lines.pop(); | ||
lines.forEach(function(line, index) { | ||
line = line.replace("\r", ''); | ||
self.emit('line', line); | ||
@@ -30,3 +33,2 @@ }); | ||
if (buffer.length > 0) { | ||
buffer = buffer.replace("\r", ''); | ||
self.emit('line', buffer); | ||
@@ -43,5 +45,5 @@ buffer = ''; | ||
exports.carry = function(reader, listener, encoding) { | ||
return new Carrier(reader, listener, encoding); | ||
exports.carry = function(reader, listener, encoding, separator) { | ||
return new Carrier(reader, listener, encoding, separator); | ||
} | ||
{ "name" : "carrier" | ||
, "description" : "Evented stream line reader for node.js" | ||
, "version" : "0.1.6" | ||
, "version" : "0.1.7" | ||
, "homepage" : "http://github.com/pgte/carrier" | ||
@@ -20,2 +20,6 @@ , "author" : | ||
} | ||
, { | ||
"name": "Patrick Georgi" | ||
, "url": "https://github.com/pgeorgi" | ||
} | ||
] | ||
@@ -22,0 +26,0 @@ , "repository" : |
Sorry, the diff of this file is not supported yet
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
8282
67795
10
186
44
5