22
33import { evaluatePath , setPath } from 'doc-path' ;
44import { defaultJson2CsvOptions , defaultCsv2JsonOptions } from './constants' ;
5- import type { Json2CsvOptions , Csv2JsonOptions , FullJson2CsvOptions , FullCsv2JsonOptions } from './types' ;
5+ import type { Json2CsvOptions , Csv2JsonOptions , DefaultJson2CsvOptions , FullCsv2JsonOptions } from './types' ;
66
77const dateStringRegex = / \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } .\d { 3 } Z / ,
88 MAX_ARRAY_LENGTH = 100000 ;
@@ -12,7 +12,7 @@ const dateStringRegex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,
1212 * If a user does not provide custom options, then we use our default
1313 * If options are provided, then we set each valid key that was passed
1414 */
15- export function buildJ2COptions ( opts : Json2CsvOptions ) : FullJson2CsvOptions {
15+ export function buildJ2COptions ( opts : Json2CsvOptions ) : DefaultJson2CsvOptions {
1616 return {
1717 ...defaultJson2CsvOptions ,
1818 ...opts ,
@@ -21,7 +21,7 @@ export function buildJ2COptions(opts: Json2CsvOptions): FullJson2CsvOptions {
2121 wrap : opts ?. delimiter ?. wrap || defaultJson2CsvOptions . delimiter . wrap ,
2222 eol : opts ?. delimiter ?. eol || defaultJson2CsvOptions . delimiter . eol ,
2323 } ,
24- fieldTitleMap : Object . create ( { } ) ,
24+ fieldTitleMap : opts ?. fieldTitleMap || Object . create ( { } ) ,
2525 } ;
2626}
2727
@@ -60,7 +60,7 @@ export function deepCopy<T>(obj: T): T {
6060 * of a string. Given the RFC4180 requirements, that means that the value is
6161 * wrapped in value wrap delimiters (usually a quotation mark on each side).
6262 */
63- export function isStringRepresentation ( fieldValue : string , options : FullJson2CsvOptions | FullCsv2JsonOptions ) {
63+ export function isStringRepresentation ( fieldValue : string , options : DefaultJson2CsvOptions | FullCsv2JsonOptions ) {
6464 const firstChar = fieldValue [ 0 ] ,
6565 lastIndex = fieldValue . length - 1 ,
6666 lastChar = fieldValue [ lastIndex ] ;
0 commit comments