json-2-csv
Advanced tools
Comparing version 3.7.11 to 3.7.12
{ | ||
"author": { | ||
"name": "Mike Rodrigues", | ||
"email": "rodrigues.mi@husky.neu.edu" | ||
"email": "rodrigues.mi@northeastern.edu" | ||
}, | ||
"name": "json-2-csv", | ||
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.", | ||
"version": "3.7.11", | ||
"version": "3.7.12", | ||
"repository": { | ||
@@ -45,8 +45,8 @@ "type": "git", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "7.10.0", | ||
"mocha": "8.1.3", | ||
"eslint": "7.14.0", | ||
"mocha": "8.2.1", | ||
"nyc": "15.1.0", | ||
"should": "13.2.3", | ||
"tslint": "6.1.3", | ||
"typescript": "4.0.3" | ||
"typescript": "4.1.2" | ||
}, | ||
@@ -53,0 +53,0 @@ "engines": { |
@@ -36,2 +36,3 @@ { | ||
"unwindArrays": false, | ||
"useDateIso8601Format": false, | ||
"useLocaleFormat": false | ||
@@ -38,0 +39,0 @@ }, |
@@ -162,3 +162,3 @@ 'use strict'; | ||
*/ | ||
function unwindRecordsIfNecessary(params) { | ||
function unwindRecordsIfNecessary(params, finalPass = false) { | ||
if (options.unwindArrays) { | ||
@@ -182,2 +182,8 @@ const originalRecordsLength = params.records.length; | ||
// Run a final time in case the earlier unwinding exposed additional | ||
// arrays to unwind... | ||
if (!finalPass) { | ||
return unwindRecordsIfNecessary(params, true); | ||
} | ||
// If keys were provided, set the headerFields to the provided keys: | ||
@@ -184,0 +190,0 @@ if (options.keys) { |
@@ -6,3 +6,4 @@ 'use strict'; | ||
const dateStringRegex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/; | ||
const dateStringRegex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/, | ||
MAX_ARRAY_LENGTH = 100000; | ||
@@ -289,2 +290,15 @@ module.exports = { | ||
function flatten(array) { | ||
// Node 11+ - use the native array flattening function | ||
if (array.flat) { | ||
return array.flat(); | ||
} | ||
// #167 - allow browsers to flatten very long 200k+ element arrays | ||
if (array.length > MAX_ARRAY_LENGTH) { | ||
let safeArray = []; | ||
for (let a = 0; a < array.length; a += MAX_ARRAY_LENGTH) { | ||
safeArray = safeArray.concat(...array.slice(a, a + MAX_ARRAY_LENGTH)); | ||
} | ||
return safeArray; | ||
} | ||
return [].concat(...array); | ||
@@ -291,0 +305,0 @@ } |
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
62464
1154