@@ -5192,18 +5192,18 @@ var csv_parse_sync = (function (exports) {
51925192 `got ${ JSON . stringify ( options . columns ) } `
51935193 ] , options ) ;
51945194 }
5195- // Normalize option `columns_duplicates_to_array `
5196- if ( options . columns_duplicates_to_array === undefined || options . columns_duplicates_to_array === null || options . columns_duplicates_to_array === false ) {
5197- options . columns_duplicates_to_array = false ;
5198- } else if ( options . columns_duplicates_to_array !== true ) {
5199- throw new CsvError ( 'CSV_INVALID_OPTION_COLUMNS_DUPLICATES_TO_ARRAY ' , [
5200- 'Invalid option columns_duplicates_to_array :' ,
5195+ // Normalize option `group_columns_by_name `
5196+ if ( options . group_columns_by_name === undefined || options . group_columns_by_name === null || options . group_columns_by_name === false ) {
5197+ options . group_columns_by_name = false ;
5198+ } else if ( options . group_columns_by_name !== true ) {
5199+ throw new CsvError ( 'CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME ' , [
5200+ 'Invalid option group_columns_by_name :' ,
52015201 'expect an boolean,' ,
5202- `got ${ JSON . stringify ( options . columns_duplicates_to_array ) } `
5202+ `got ${ JSON . stringify ( options . group_columns_by_name ) } `
52035203 ] , options ) ;
52045204 } else if ( options . columns === false ) {
5205- throw new CsvError ( 'CSV_INVALID_OPTION_COLUMNS_DUPLICATES_TO_ARRAY ' , [
5206- 'Invalid option columns_duplicates_to_array :' ,
5205+ throw new CsvError ( 'CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME ' , [
5206+ 'Invalid option group_columns_by_name :' ,
52075207 'the `columns` mode must be activated.'
52085208 ] , options ) ;
52095209 }
@@ -5859,7 +5859,7 @@ var csv_parse_sync = (function (exports) {
58595859 }
58605860 }
58615861 __onRecord ( ) {
5862- const { columns, columns_duplicates_to_array , encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_records_with_empty_values} = this . options ;
5862+ const { columns, group_columns_by_name , encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_records_with_empty_values} = this . options ;
58635863 const { enabled, record} = this . state ;
58645864 if ( enabled === false ) {
58655865 return this . __resetRecord ( ) ;
@@ -5923,7 +5923,7 @@ var csv_parse_sync = (function (exports) {
59235923 for ( let i = 0 , l = record . length ; i < l ; i ++ ) {
59245924 if ( columns [ i ] === undefined || columns [ i ] . disabled ) continue ;
59255925 // Turn duplicate columns into an array
5926- if ( columns_duplicates_to_array === true && obj [ columns [ i ] . name ] !== undefined ) {
5926+ if ( group_columns_by_name === true && obj [ columns [ i ] . name ] !== undefined ) {
59275927 if ( Array . isArray ( obj [ columns [ i ] . name ] ) ) {
59285928 obj [ columns [ i ] . name ] = obj [ columns [ i ] . name ] . concat ( record [ i ] ) ;
59295929 } else {
0 commit comments