json-2-csv
Advanced tools
Comparing version 1.5.0 to 2.0.0
{ | ||
"name": "json-2-csv", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/mrodrig/json-2-csv", | ||
@@ -5,0 +5,0 @@ "moduleType": [ |
@@ -26,5 +26,5 @@ { | ||
"ARRAY" : ";", | ||
"WRAP" : "" | ||
"WRAP" : "", | ||
"EOL" : "\n" | ||
}, | ||
"EOL" : "\n", | ||
"PREPEND_HEADER" : true, | ||
@@ -31,0 +31,0 @@ "SORT_HEADER" : false, |
@@ -6,3 +6,3 @@ 'use strict'; | ||
constants = require('./constants'), // Require in constants | ||
Promise = require('bluebird'), | ||
docPath = require('doc-path'), | ||
_ = require('underscore'); // Require underscore | ||
@@ -21,2 +21,6 @@ | ||
var buildOptions = function (opts, cb) { | ||
// PREVIOUS VERSION SUPPORT (so that future versions are backwards compatible) | ||
// Issue #26: opts.EOL should be opts.DELIMITER.EOL -- this will move the option & provide backwards compatibility | ||
if (docPath.evaluatePath(opts, 'EOL')) { docPath.setPath(opts, 'DELIMITER.EOL'); } | ||
opts = _.defaults(opts || {}, defaultOptions); | ||
@@ -23,0 +27,0 @@ |
@@ -208,3 +208,3 @@ 'use strict'; | ||
// Split the CSV into lines using the specified EOL option | ||
var lines = data.split(options.EOL), | ||
var lines = data.split(options.DELIMITER.EOL), | ||
json = convertCSV(lines, callback); // Retrieve the JSON document array | ||
@@ -211,0 +211,0 @@ return callback(null, json); // Send the data back to the caller |
@@ -153,3 +153,3 @@ 'use strict'; | ||
return [headingKeys].concat(_.reduce(data, function (csv, doc) { | ||
return csv += convertData(doc, headingKeys).join(options.DELIMITER.FIELD) + options.EOL; | ||
return csv += convertData(doc, headingKeys).join(options.DELIMITER.FIELD) + options.DELIMITER.EOL; | ||
}, '')); | ||
@@ -203,3 +203,3 @@ }; | ||
// If we are prepending the header, then join the header and data by EOL, otherwise just return the data | ||
return callback(null, options.PREPEND_HEADER ? csvHeading + options.EOL + csvData : csvData); | ||
return callback(null, options.PREPEND_HEADER ? csvHeading + options.DELIMITER.EOL + csvData : csvData); | ||
}) | ||
@@ -206,0 +206,0 @@ .catch(function (err) { |
@@ -5,3 +5,3 @@ { | ||
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -37,6 +37,4 @@ # Convert JSON to CSV or CSV to JSON | ||
* `WRAP` - String - Wrap values in the delimiter of choice (e.g. wrap values in quotes). Default: `''` | ||
* `CHECK_SCHEMA_DIFFERENCES` - Boolean - Should we require all documents to have the same schema? Default: `true` | ||
* `EOL` - String - End of Line Delimiter. Default: `'\n'` | ||
* `PREPEND_HEADER` - Boolean - Should the auto-generated header be prepended as the first line in the CSV? Default: `true` | ||
* `SORT_HEADER` - Boolean - Should the auto-generated header be sorted? Default: `false` | ||
* `EOL` - String - End of Line Delimiter. Default: `'\n'` | ||
* `KEYS` - Array - Specify the keys (as strings) that should be converted. Default: `null` | ||
@@ -97,3 +95,3 @@ * If you have a nested object (ie. {info : {name: 'Mike'}}), then set options.KEYS to ['info.name'] | ||
* `WRAP` - String - The character that field values are wrapped in. Default: `''` | ||
* `EOL` - String - End of Line Delimiter. Default: `'\n'` | ||
* `EOL` - String - End of Line Delimiter. Default: `'\n'` | ||
* `PARSE_CSV_NUMBERS` - Boolean - (TODO) Should numbers that are found in the CSV be converted to numbers? Default: `false` | ||
@@ -100,0 +98,0 @@ * `KEYS` - Array - Specify the keys (as strings) that should be converted. Default: `null` |
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
30278
491
229