csv-stringify
Advanced tools
Comparing version 5.1.1 to 5.1.2
# Changelog | ||
## Version 5.1.2 | ||
Fix: | ||
* write: immutable input chunks | ||
## Version 5.1.1 | ||
@@ -8,3 +14,3 @@ | ||
* ts: add casting context missing type | ||
* ts: add casting context missing type | ||
@@ -11,0 +17,0 @@ ## Version 5.1.0 |
@@ -395,7 +395,7 @@ "use strict"; | ||
key: "stringify", | ||
value: function stringify(record) { | ||
var _record, column, columns, containsEscape, containsQuote, containsRowDelimiter, containsdelimiter, delimiter, err, escape, field, header, i, j, l, len, m, newrecord, quote, quoted, quotedMatch, quotedString, ref, ref1, regexp, shouldQuote, value; | ||
value: function stringify(chunk) { | ||
var column, columns, containsEscape, containsQuote, containsRowDelimiter, containsdelimiter, delimiter, err, escape, field, header, i, j, l, len, m, newrecord, quote, quoted, quotedMatch, quotedString, record, ref, ref1, regexp, shouldQuote, value; | ||
if (_typeof(record) !== 'object') { | ||
return record; | ||
if (_typeof(chunk) !== 'object') { | ||
return chunk; | ||
} | ||
@@ -409,14 +409,14 @@ | ||
escape = _this$options.escape; | ||
record = []; // Record is an array | ||
// Record is an array | ||
if (Array.isArray(record)) { | ||
if (Array.isArray(chunk)) { | ||
if (columns) { | ||
// We are getting an array but the user has specified output columns. In | ||
// this case, we respect the columns indexes | ||
record.splice(columns.length); | ||
chunk.splice(columns.length); | ||
} // Cast record elements | ||
for (i = j = 0, len = record.length; j < len; i = ++j) { | ||
field = record[i]; | ||
for (i = j = 0, len = chunk.length; j < len; i = ++j) { | ||
field = chunk[i]; | ||
@@ -444,7 +444,5 @@ var _this$__cast = this.__cast(field, { | ||
// Record is a literal object | ||
_record = []; | ||
if (columns) { | ||
for (i = l = 0, ref = columns.length; 0 <= ref ? l < ref : l > ref; i = 0 <= ref ? ++l : --l) { | ||
field = get(record, columns[i].key); | ||
field = get(chunk, columns[i].key); | ||
@@ -468,7 +466,7 @@ var _this$__cast3 = this.__cast(field, { | ||
_record[i] = [value, field]; | ||
record[i] = [value, field]; | ||
} | ||
} else { | ||
for (column in record) { | ||
field = record[column]; | ||
for (column in chunk) { | ||
field = chunk[column]; | ||
@@ -492,8 +490,5 @@ var _this$__cast5 = this.__cast(field, { | ||
_record.push([value, field]); | ||
record.push([value, field]); | ||
} | ||
} | ||
record = _record; | ||
_record = null; | ||
} | ||
@@ -500,0 +495,0 @@ |
@@ -309,18 +309,19 @@ // Generated by CoffeeScript 2.3.2 | ||
// Convert a line to a string. Line may be an object, an array or a string. | ||
stringify(record) { | ||
var _record, column, columns, containsEscape, containsQuote, containsRowDelimiter, containsdelimiter, delimiter, err, escape, field, header, i, j, l, len, m, newrecord, quote, quoted, quotedMatch, quotedString, ref, ref1, regexp, shouldQuote, value; | ||
if (typeof record !== 'object') { | ||
return record; | ||
stringify(chunk) { | ||
var column, columns, containsEscape, containsQuote, containsRowDelimiter, containsdelimiter, delimiter, err, escape, field, header, i, j, l, len, m, newrecord, quote, quoted, quotedMatch, quotedString, record, ref, ref1, regexp, shouldQuote, value; | ||
if (typeof chunk !== 'object') { | ||
return chunk; | ||
} | ||
({columns, delimiter, header, quote, escape} = this.options); | ||
record = []; | ||
// Record is an array | ||
if (Array.isArray(record)) { | ||
if (Array.isArray(chunk)) { | ||
if (columns) { | ||
// We are getting an array but the user has specified output columns. In | ||
// this case, we respect the columns indexes | ||
record.splice(columns.length); | ||
chunk.splice(columns.length); | ||
} | ||
// Cast record elements | ||
for (i = j = 0, len = record.length; j < len; i = ++j) { | ||
field = record[i]; | ||
for (i = j = 0, len = chunk.length; j < len; i = ++j) { | ||
field = chunk[i]; | ||
[err, value] = this.__cast(field, { | ||
@@ -340,6 +341,5 @@ index: i, | ||
// Record is a literal object | ||
_record = []; | ||
if (columns) { | ||
for (i = l = 0, ref = columns.length; (0 <= ref ? l < ref : l > ref); i = 0 <= ref ? ++l : --l) { | ||
field = get(record, columns[i].key); | ||
field = get(chunk, columns[i].key); | ||
[err, value] = this.__cast(field, { | ||
@@ -355,7 +355,7 @@ index: i, | ||
} | ||
_record[i] = [value, field]; | ||
record[i] = [value, field]; | ||
} | ||
} else { | ||
for (column in record) { | ||
field = record[column]; | ||
for (column in chunk) { | ||
field = chunk[column]; | ||
[err, value] = this.__cast(field, { | ||
@@ -371,7 +371,5 @@ index: i, | ||
} | ||
_record.push([value, field]); | ||
record.push([value, field]); | ||
} | ||
} | ||
record = _record; | ||
_record = null; | ||
} | ||
@@ -378,0 +376,0 @@ if (Array.isArray(record)) { |
{ | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"name": "csv-stringify", | ||
@@ -4,0 +4,0 @@ "description": "CSV stringifier implementing the Node.js `stream.Transform` API", |
@@ -26,3 +26,3 @@ | ||
* to be used conjointly with `csv-generate`, `csv-parse` and `stream-transform` | ||
* BSD License | ||
* MIT License | ||
@@ -29,0 +29,0 @@ ## Usage |
54488
19
1319