Comparing version 0.1.1 to 0.1.2
var fs = require("fs"), | ||
extended = require("./extended"), | ||
isUndefinedOrNull = extended.isUndefinedOrNull, | ||
hash = extended.hash, | ||
@@ -32,7 +33,9 @@ stream = require("stream"), | ||
return function escapeFields(fields) { | ||
var i = -1, l = fields.length, ret = []; | ||
var i = -1, l = fields.length, ret = [], field; | ||
while (++i < l) { | ||
ret.push(escapeField(fields[i])); | ||
field = fields[i]; | ||
field = (isUndefinedOrNull(field) ? "" : field) + ""; | ||
ret.push(escapeField(field)); | ||
} | ||
return ret.join(delimiter) + LINE_BREAK; | ||
return ret.join(delimiter); | ||
}; | ||
@@ -63,3 +66,3 @@ } | ||
} | ||
writer.push(ret.join("")); | ||
writer.push(ret.join("\n")); | ||
} | ||
@@ -76,7 +79,3 @@ } | ||
function writeToStream(ws, arr, options) { | ||
var writer = new stream.Readable(); | ||
__write(writer, arr, options); | ||
writer.push(null); | ||
writer.pipe(ws); | ||
return writer; | ||
return write(arr, options).pipe(ws); | ||
} | ||
@@ -83,0 +82,0 @@ |
@@ -39,6 +39,25 @@ var extended = require("./extended"), | ||
var origOn = ParserStream.prototype.on; | ||
var origOn = ParserStream.prototype.on, | ||
origPause = ParserStream.prototype.pause, | ||
origResume = ParserStream.prototype.resume; | ||
function pause() { | ||
origPause.apply(this, arguments); | ||
this.paused = true; | ||
this.pause = pause; | ||
} | ||
function resume() { | ||
origResume.apply(this, arguments); | ||
this.paused = false; | ||
if (this.__pausedDone) { | ||
this.__pausedDone(); | ||
} | ||
this.resume = resume; | ||
} | ||
extended(ParserStream).extend({ | ||
__pausedDone: null, | ||
__parseLine: function __parseLineData(data, index, ignore) { | ||
@@ -115,3 +134,7 @@ var ignoreEmpty = this._ignoreEmpty; | ||
} | ||
done(); | ||
if (!this.paused) { | ||
done(); | ||
} else { | ||
this.__pausedDone = done; | ||
} | ||
}, | ||
@@ -132,2 +155,21 @@ | ||
pause: function () { | ||
if (!this.paused) { | ||
this.paused = true; | ||
this.emit("pause"); | ||
} | ||
}, | ||
resume: function () { | ||
if (this.paused) { | ||
this.paused = false; | ||
if (this.__pausedDone) { | ||
var done = this.__pausedDone; | ||
this.__pausedDone = null; | ||
done(); | ||
} | ||
this.emit("resume"); | ||
} | ||
}, | ||
on: function (evt) { | ||
@@ -134,0 +176,0 @@ if (evt === "data" || evt === "readable") { |
{ | ||
"name": "fast-csv", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "CSV parser for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
59472930
932