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 2.0.2 to 2.0.3

14

lib/csv-2-json.js

@@ -67,4 +67,4 @@ 'use strict';

var createDocument = function (keys, line) {
var line = splitLine(line), // Split the line using the given field delimiter after trimming whitespace
val; // Temporary variable to set the current key's value to
line = splitLine(line); // Split the line using the given field delimiter after trimming whitespace
var val; // Temporary variable to set the current key's value to

@@ -164,10 +164,10 @@ // Reduce the keys into a JSON document representing the given line

// If we reached a field delimiter and are not inside the wrap delimiters (ie. *,*)
else if (character === options.DELIMITER.FIELD && charBefore !== options.DELIMITER.WRAP
&& charAfter !== options.DELIMITER.WRAP && !stateVariables.insideWrapDelimiter
&& stateVariables.parsingValue) {
else if (character === options.DELIMITER.FIELD && charBefore !== options.DELIMITER.WRAP &&
charAfter !== options.DELIMITER.WRAP && !stateVariables.insideWrapDelimiter &&
stateVariables.parsingValue) {
splitLine.push(line.substring(stateVariables.startIndex, index));
stateVariables.startIndex = index + 1;
}
else if (character === options.DELIMITER.FIELD && charBefore === options.DELIMITER.WRAP
&& charAfter !== options.DELIMITER.WRAP) {
else if (character === options.DELIMITER.FIELD && charBefore === options.DELIMITER.WRAP &&
charAfter !== options.DELIMITER.WRAP) {
stateVariables.insideWrapDelimiter = false;

@@ -174,0 +174,0 @@ stateVariables.parsingValue = true;

@@ -6,3 +6,3 @@ 'use strict';

path = require('doc-path'),
Promise = require('bluebird');
promise = require('bluebird');

@@ -15,6 +15,6 @@ var options = {}; // Initialize the options - this will be populated when the json2csv function is called.

* @param data
* @returns {Promise}
* @returns {promise}
*/
var generateHeading = function(data) {
if (options.KEYS) { return Promise.resolve(options.KEYS); }
if (options.KEYS) { return promise.resolve(options.KEYS); }

@@ -35,3 +35,3 @@ var keys = _.map(data, function (document, indx) { // for each key

if (keys && keys.length <= 1) {
return Promise.resolve(_.flatten(keys) || []);
return promise.resolve(_.flatten(keys) || []);
}

@@ -52,3 +52,3 @@ // else - multiple documents - ensure only one schema (regardless of field ordering)

if (schemaDifferences) {
return Promise.reject(new Error(constants.Errors.json2csv.notSameSchema));
return promise.reject(new Error(constants.Errors.json2csv.notSameSchema));
}

@@ -69,3 +69,3 @@

return Promise.resolve(uniqueKeys);
return promise.resolve(uniqueKeys);
};

@@ -72,0 +72,0 @@

@@ -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": "2.0.2",
"version": "2.0.3",
"repository": {

@@ -30,3 +30,3 @@ "type": "git",

"doc-path": "~1.0.3",
"bluebird": "~2.10.1"
"bluebird": "~2.10.2"
},

@@ -33,0 +33,0 @@ "devDependencies": {

@@ -5,4 +5,5 @@ # Convert JSON to CSV or CSV to JSON

![David - Dependency Checker Icon](https://david-dm.org/mrodrig/json-2-csv.png "json-2-csv Dependency Status")
[![NPM version](http://img.shields.io/npm/dm/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
[![Downloads](http://img.shields.io/npm/dm/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
[![NPM version](https://img.shields.io/npm/v/json-2-csv.svg)](https://www.npmjs.org/package/json-2-csv)
[![bitHound Score](https://www.bithound.io/github/mrodrig/json-2-csv/badges/score.svg)](https://www.bithound.io/github/mrodrig/json-2-csv)

@@ -9,0 +10,0 @@ This node module will convert an array of JSON documents to a CSV string.

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