csv-stringify
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -210,3 +210,3 @@ // Generated by CoffeeScript 1.10.0 | ||
Stringifier.prototype.stringify = function(line) { | ||
var _line, column, columns, containsLinebreak, containsQuote, containsdelimiter, delimiter, escape, field, i, j, l, newLine, quote, ref, ref1, regexp, value; | ||
var _line, column, columns, containsEscape, containsLinebreak, containsQuote, containsdelimiter, delimiter, escape, field, i, j, l, newLine, quote, ref, ref1, regexp, shouldQuote, value; | ||
if (typeof line !== 'object') { | ||
@@ -258,3 +258,9 @@ return line; | ||
containsQuote = field.indexOf(quote) >= 0; | ||
containsEscape = field.indexOf(escape) >= 0 && (escape !== quote); | ||
containsLinebreak = field.indexOf('\r') >= 0 || field.indexOf('\n') >= 0; | ||
shouldQuote = containsQuote || containsdelimiter || containsLinebreak || this.options.quoted || (this.options.quotedString && typeof line[i] === 'string'); | ||
if (shouldQuote && containsEscape) { | ||
regexp = escape === '\\' ? new RegExp(escape + escape, 'g') : new RegExp(escape, 'g'); | ||
field = field.replace(regexp, escape + escape); | ||
} | ||
if (containsQuote) { | ||
@@ -264,3 +270,3 @@ regexp = new RegExp(quote, 'g'); | ||
} | ||
if (containsQuote || containsdelimiter || containsLinebreak || this.options.quoted || (this.options.quotedString && typeof line[i] === 'string')) { | ||
if (shouldQuote) { | ||
field = quote + field + quote; | ||
@@ -267,0 +273,0 @@ } |
{ | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"name": "csv-stringify", | ||
@@ -4,0 +4,0 @@ "description": "CSV stringifier implementing the Node.js `stream.Transform` API", |
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
14018
312