diff --git a/package-lock.json b/package-lock.json index 9f3abf8..b9b01ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "json-2-csv", - "version": "5.5.5", + "version": "5.5.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "json-2-csv", - "version": "5.5.5", + "version": "5.5.6", "license": "MIT", "dependencies": { "deeks": "3.1.0", @@ -3296,12 +3296,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { diff --git a/src/json2csv.ts b/src/json2csv.ts index 14501f0..13ddc38 100755 --- a/src/json2csv.ts +++ b/src/json2csv.ts @@ -6,7 +6,7 @@ import { excelBOM, errors } from './constants'; import * as utils from './utils'; import type { FullJson2CsvOptions, Json2CsvParams } from './types'; -export const Json2Csv = function(options: FullJson2CsvOptions) { +export const Json2Csv = function (options: FullJson2CsvOptions) { const wrapDelimiterCheckRegex = new RegExp(options.delimiter.wrap, 'g'), crlfSearchRegex = /\r?\n|\r/, customValueParser = options.parseValue && typeof options.parseValue === 'function' ? options.parseValue : null, @@ -58,8 +58,8 @@ export const Json2Csv = function(options: FullJson2CsvOptions) { function checkSchemaDifferences(documentSchemas: string[][]) { // have multiple documents - ensure only one schema (regardless of field ordering) const firstDocSchema = documentSchemas[0], - restOfDocumentSchemas = documentSchemas.slice(1), - schemaDifferences = computeNumberOfSchemaDifferences(firstDocSchema, restOfDocumentSchemas); + restOfDocumentSchemas = documentSchemas.slice(1), + schemaDifferences = computeNumberOfSchemaDifferences(firstDocSchema, restOfDocumentSchemas); // If there are schema inconsistencies, throw a schema not the same error if (schemaDifferences) { @@ -134,7 +134,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) { function wrapHeaderFields(params: Json2CsvParams) { // only perform this if we are actually prepending the header if (options.prependHeader) { - params.headerFields = params.headerFields.map(function(headingKey) { + params.headerFields = params.headerFields.map(function (headingKey) { return wrapFieldValueIfNecessary(headingKey); }); } @@ -149,13 +149,13 @@ export const Json2Csv = function(options: FullJson2CsvOptions) { const fieldTitleMapKeys = Object.keys(options.fieldTitleMap); params.header = params.headerFields - .map(function(field) { + .map(function (field) { let headerKey = field; // If a custom field title was provided for this field, use that if (fieldTitleMapKeys.includes(field)) { headerKey = options.fieldTitleMap[field]; - } else if (!options.escapeHeaderNestedDots) { + } else if (!options.escapeHeaderNestedDots) { // Otherwise, if the user doesn't want nested dots in keys to be escaped, then unescape them headerKey = headerKey.replace(/\\\./g, '.'); } @@ -188,7 +188,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) { } else if (item?.wildcardMatch) { // Return "field" value for objects with wildcardMatch: true return item.field; - } + } // Exclude other objects return []; }); @@ -206,7 +206,7 @@ export const Json2Csv = function(options: FullJson2CsvOptions) { if (options.keys) { options.keys = keyStrings; - + const matchedKeys = keyStrings.flatMap((userProvidedKey) => { // If this is not a wildcard matched key, then just return and include it in the resulting key list if (!wildcardMatchKeys.includes(userProvidedKey)) {