Socket
Socket
Sign inDemoInstall

json-2-csv

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-2-csv - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

1

lib/constants.json

@@ -30,2 +30,3 @@ {

"PREPEND_HEADER" : true,
"SORT_HEADER" : false,
"PARSE_CSV_NUMBERS" : false,

@@ -32,0 +33,0 @@ "KEYS" : null,

@@ -50,3 +50,10 @@ 'use strict';

return Promise.resolve(_.flatten(keys[0]));
var result = _.flatten(keys[0]);
if (options.SORT_HEADER) {
result.sort();
}
return Promise.resolve(result);
}

@@ -61,2 +68,6 @@

if (options.SORT_HEADER) {
uniqueKeys.sort();
}
return Promise.resolve(uniqueKeys);

@@ -113,3 +124,12 @@ };

if (_.isArray(value)) { // We have an array of values
return options.DELIMITER.WRAP + '[' + value.join(options.DELIMITER.ARRAY) + ']' + options.DELIMITER.WRAP;
var result = [];
value.forEach(function(item) {
if (_.isObject(item)) {
// use JSON stringify to convert objects in arrays, otherwise toString() will just return [object Object]
result.push(JSON.stringify(item));
} else {
result.push(item);
}
});
return options.DELIMITER.WRAP + '[' + result.join(options.DELIMITER.ARRAY) + ']' + options.DELIMITER.WRAP;
} else if (_.isDate(value)) { // If we have a date

@@ -121,2 +141,4 @@ return options.DELIMITER.WRAP + value.toString() + options.DELIMITER.WRAP;

return options.DELIMITER.WRAP + value.toString() + options.DELIMITER.WRAP;
} else if (_.isBoolean(value)) { // If we have a boolean (avoids false being converted to '')
return options.DELIMITER.WRAP + value.toString() + options.DELIMITER.WRAP;
}

@@ -123,0 +145,0 @@ return options.DELIMITER.WRAP + (value ? value.toString() : '') + options.DELIMITER.WRAP; // Otherwise push the current value

14

package.json

@@ -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.4.0",
"version": "1.5.0",
"repository": {

@@ -29,10 +29,10 @@ "type": "git",

"underscore": "~1.8.3",
"doc-path": "~1.0.0",
"bluebird": "~2.9.24"
"doc-path": "~1.0.3",
"bluebird": "~2.10.1"
},
"devDependencies": {
"mocha": "~2.2.4",
"istanbul": "~0.3.13",
"should": "~5.2.0",
"async": "~0.9.0"
"mocha": "~2.3.3",
"istanbul": "~0.3.20",
"should": "~7.1.0",
"async": "~1.4.2"
},

@@ -39,0 +39,0 @@ "engines": {

@@ -39,2 +39,3 @@ # Convert JSON to CSV or CSV to JSON

* `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'`

@@ -41,0 +42,0 @@ * `KEYS` - Array - Specify the keys (as strings) that should be converted. Default: `null`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc