Socket
Socket
Sign inDemoInstall

json2csv

Package Overview
Dependencies
Maintainers
4
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json2csv - npm Package Compare versions

Comparing version 5.0.3 to 5.0.4

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [5.0.4](https://github.com/zemirco/json2csv/compare/v5.0.3...v5.0.4) (2020-11-10)
### Bug Fixes
* Fix issue with unwind and empty arrays creating an extra column ([#496](https://github.com/zemirco/json2csv/issues/496)) ([0b331fc](https://github.com/zemirco/json2csv/commit/0b331fc3ad345f8062abe60f64cb3b43dad30fb0))
### [5.0.3](https://github.com/zemirco/json2csv/compare/v5.0.2...v5.0.3) (2020-09-24)

@@ -7,0 +14,0 @@

4

lib/transforms/unwind.js
const lodashGet = require('lodash.get');
const { setProp, flattenReducer } = require('../utils');
const { setProp, unsetProp, flattenReducer } = require('../utils');

@@ -45,3 +45,3 @@ function getUnwindablePaths(obj, currentPath) {

if (!unwindArray.length) {
return setProp(row, unwindPath, undefined);
return unsetProp(row, unwindPath);
}

@@ -48,0 +48,0 @@

@@ -9,7 +9,25 @@ 'use strict';

const pathArray = Array.isArray(path) ? path : path.split('.');
const key = pathArray[0];
const newValue = pathArray.length > 1 ? setProp(obj[key] || {}, pathArray.slice(1), value) : value;
const [key, ...restPath] = pathArray;
const newValue = pathArray.length > 1 ? setProp(obj[key] || {}, restPath, value) : value;
return Object.assign({}, obj, { [key]: newValue });
}
function unsetProp(obj, path) {
const pathArray = Array.isArray(path) ? path : path.split('.');
const [key, ...restPath] = pathArray;
if (typeof obj[key] !== 'object') {
// This will never be hit in the current code because unwind does the check before calling unsetProp
/* istanbul ignore next */
return obj;
}
if (pathArray.length === 1) {
delete obj[key];
return obj;
}
return unsetProp(obj[key], restPath);
}
function flattenReducer(acc, arr) {

@@ -45,4 +63,5 @@ try {

setProp,
unsetProp,
fastJoin,
flattenReducer
};
{
"name": "json2csv",
"version": "5.0.3",
"version": "5.0.4",
"description": "Convert JSON to CSV",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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