csv-streamify
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -15,3 +15,7 @@ var Transform = require('stream').Transform, | ||
module.exports = function (opts, cb) { return new CSVStream(opts, cb) } | ||
module.exports = function (opts, cb) { | ||
var s = new CSVStream(opts, cb) | ||
if (typeof cb === 'function') s.on('error', cb) | ||
return s | ||
} | ||
@@ -39,6 +43,4 @@ module.exports.CSVStream = CSVStream | ||
this.quote = opts.quote || '\"' | ||
this.empty = '' | ||
this.empty = opts.hasOwnProperty('empty') ? opts.empty : '' | ||
if (opts.hasOwnProperty('empty')) this.empty = opts.empty | ||
// state | ||
@@ -50,6 +52,2 @@ this.body = [] | ||
this.lineNo = 0 | ||
if (this.cb) { | ||
this.on('error', this.cb) | ||
} | ||
} | ||
@@ -67,3 +65,2 @@ | ||
} catch (err) { | ||
if (this.cb) this.cb(err) | ||
done(err) | ||
@@ -101,5 +98,3 @@ } | ||
// reset state | ||
this.field = '' | ||
this.line = [] | ||
this.isQuoted = false | ||
this._reset() | ||
continue | ||
@@ -113,5 +108,13 @@ } | ||
CSVStream.prototype.end = function (buf) { | ||
if (this.cb) this.cb(null, this.body) | ||
Transform.prototype.end.call(this, buf) | ||
CSVStream.prototype._reset = function () { | ||
this.field = '' | ||
this.line = [] | ||
this.isQuoted = false | ||
} | ||
CSVStream.prototype.end = function (buf, encoding) { | ||
var self = this | ||
Transform.prototype.end.call(this, buf, encoding, function () { | ||
if (self.cb) self.cb(null, self.body) | ||
}) | ||
} |
{ | ||
"name": "csv-streamify", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Streaming CSV Parser. Made entirely out of streams.", | ||
@@ -5,0 +5,0 @@ "author": "Clemens Stolle", |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
5274
5
90