From aa432c1251327b579ee7f71bd9fd776021ac1f1e Mon Sep 17 00:00:00 2001 From: David Worms Date: Sun, 7 Nov 2021 00:21:23 +0100 Subject: [PATCH] refactor(csv-parse)!: rename skip_records_with_empty_values --- packages/csv-parse/ROADMAP.md | 1 - packages/csv-parse/dist/cjs/index.cjs | 14 +++++------ packages/csv-parse/dist/cjs/index.d.ts | 4 ++-- packages/csv-parse/dist/cjs/sync.cjs | 14 +++++------ packages/csv-parse/dist/esm/index.d.ts | 4 ++-- packages/csv-parse/dist/esm/index.js | 14 +++++------ packages/csv-parse/dist/esm/sync.js | 14 +++++------ packages/csv-parse/dist/iife/index.js | 14 +++++------ packages/csv-parse/dist/iife/sync.js | 14 +++++------ packages/csv-parse/dist/umd/index.js | 14 +++++------ packages/csv-parse/dist/umd/sync.js | 14 +++++------ packages/csv-parse/lib/index.d.ts | 4 ++-- packages/csv-parse/lib/index.js | 16 ++++++------- ... option.skip_records_with_empty_values.js} | 2 +- packages/csv-parse/test/api.types.ts | 8 +++---- packages/csv-parse/test/option.columns.coffee | 4 ++-- ...ion.skip_records_with_empty_values.coffee} | 24 +++++++++---------- 17 files changed, 89 insertions(+), 90 deletions(-) rename packages/csv-parse/samples/{option.skip_lines_with_empty_values.js => option.skip_records_with_empty_values.js} (84%) rename packages/csv-parse/test/{option.skip_lines_with_empty_values.coffee => option.skip_records_with_empty_values.coffee} (63%) diff --git a/packages/csv-parse/ROADMAP.md b/packages/csv-parse/ROADMAP.md index f4a360a7f..82b35536e 100644 --- a/packages/csv-parse/ROADMAP.md +++ b/packages/csv-parse/ROADMAP.md @@ -4,7 +4,6 @@ Below is the list of upgrades we are considering for the next major release. The We invite you to join and contribute but create an issue before engaging any work. Some tasks are scheduled for another time or might depends on another one. -* `skip_lines_with_empty_values`: rename to skip_records_with_empty_values (easy) * `skip_lines_with_error`: rename to skip_records_with_error (easy) * `max_comment_size`: new option (medium) * promise: new API module (medium) diff --git a/packages/csv-parse/dist/cjs/index.cjs b/packages/csv-parse/dist/cjs/index.cjs index 71165d4e3..8720467ea 100644 --- a/packages/csv-parse/dist/cjs/index.cjs +++ b/packages/csv-parse/dist/cjs/index.cjs @@ -5453,11 +5453,11 @@ class Parser extends Transform { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5860,7 +5860,7 @@ class Parser extends Transform { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5868,7 +5868,7 @@ class Parser extends Transform { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5909,7 +5909,7 @@ class Parser extends Transform { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/cjs/index.d.ts b/packages/csv-parse/dist/cjs/index.d.ts index 4d3278561..0df5fb13a 100644 --- a/packages/csv-parse/dist/cjs/index.d.ts +++ b/packages/csv-parse/dist/cjs/index.d.ts @@ -191,8 +191,8 @@ export interface Options { /** * Don't generate records for lines containing empty column values (column matching /\s*\/), defaults to false. */ - skip_lines_with_empty_values?: boolean; - skipLinesWithEmptyValues?: boolean; + skip_records_with_empty_values?: boolean; + skipRecordsWithEmptyValues?: boolean; /** * Stop handling records after the requested number of records. */ diff --git a/packages/csv-parse/dist/cjs/sync.cjs b/packages/csv-parse/dist/cjs/sync.cjs index cc19d7223..6ca3fba4c 100644 --- a/packages/csv-parse/dist/cjs/sync.cjs +++ b/packages/csv-parse/dist/cjs/sync.cjs @@ -5453,11 +5453,11 @@ class Parser extends Transform { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5860,7 +5860,7 @@ class Parser extends Transform { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5868,7 +5868,7 @@ class Parser extends Transform { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5909,7 +5909,7 @@ class Parser extends Transform { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/esm/index.d.ts b/packages/csv-parse/dist/esm/index.d.ts index 4d3278561..0df5fb13a 100644 --- a/packages/csv-parse/dist/esm/index.d.ts +++ b/packages/csv-parse/dist/esm/index.d.ts @@ -191,8 +191,8 @@ export interface Options { /** * Don't generate records for lines containing empty column values (column matching /\s*\/), defaults to false. */ - skip_lines_with_empty_values?: boolean; - skipLinesWithEmptyValues?: boolean; + skip_records_with_empty_values?: boolean; + skipRecordsWithEmptyValues?: boolean; /** * Stop handling records after the requested number of records. */ diff --git a/packages/csv-parse/dist/esm/index.js b/packages/csv-parse/dist/esm/index.js index 5e13b6c59..156071fb4 100644 --- a/packages/csv-parse/dist/esm/index.js +++ b/packages/csv-parse/dist/esm/index.js @@ -5449,11 +5449,11 @@ class Parser extends Transform { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5856,7 +5856,7 @@ class Parser extends Transform { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5864,7 +5864,7 @@ class Parser extends Transform { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5905,7 +5905,7 @@ class Parser extends Transform { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/esm/sync.js b/packages/csv-parse/dist/esm/sync.js index 06bba8b51..f5efba2b0 100644 --- a/packages/csv-parse/dist/esm/sync.js +++ b/packages/csv-parse/dist/esm/sync.js @@ -5449,11 +5449,11 @@ class Parser extends Transform { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5856,7 +5856,7 @@ class Parser extends Transform { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5864,7 +5864,7 @@ class Parser extends Transform { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5905,7 +5905,7 @@ class Parser extends Transform { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/iife/index.js b/packages/csv-parse/dist/iife/index.js index 2b6c5e505..f3120d268 100644 --- a/packages/csv-parse/dist/iife/index.js +++ b/packages/csv-parse/dist/iife/index.js @@ -5452,11 +5452,11 @@ var csv_parse = (function (exports) { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5859,7 +5859,7 @@ var csv_parse = (function (exports) { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5867,7 +5867,7 @@ var csv_parse = (function (exports) { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5908,7 +5908,7 @@ var csv_parse = (function (exports) { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/iife/sync.js b/packages/csv-parse/dist/iife/sync.js index e899f56c1..7caf1e33a 100644 --- a/packages/csv-parse/dist/iife/sync.js +++ b/packages/csv-parse/dist/iife/sync.js @@ -5452,11 +5452,11 @@ var csv_parse_sync = (function (exports) { }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5859,7 +5859,7 @@ var csv_parse_sync = (function (exports) { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5867,7 +5867,7 @@ var csv_parse_sync = (function (exports) { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5908,7 +5908,7 @@ var csv_parse_sync = (function (exports) { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/umd/index.js b/packages/csv-parse/dist/umd/index.js index 41be5519e..7c0eea0d2 100644 --- a/packages/csv-parse/dist/umd/index.js +++ b/packages/csv-parse/dist/umd/index.js @@ -5455,11 +5455,11 @@ }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5862,7 +5862,7 @@ } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5870,7 +5870,7 @@ // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5911,7 +5911,7 @@ if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/dist/umd/sync.js b/packages/csv-parse/dist/umd/sync.js index a931a8ee5..ca7ed67b2 100644 --- a/packages/csv-parse/dist/umd/sync.js +++ b/packages/csv-parse/dist/umd/sync.js @@ -5455,11 +5455,11 @@ }else { throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean');else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean');else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else { - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean');else if(options.skip_lines_with_error === undefined || options.skip_lines_with_error === null){ @@ -5862,7 +5862,7 @@ } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -5870,7 +5870,7 @@ // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -5911,7 +5911,7 @@ if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/lib/index.d.ts b/packages/csv-parse/lib/index.d.ts index 4d3278561..0df5fb13a 100644 --- a/packages/csv-parse/lib/index.d.ts +++ b/packages/csv-parse/lib/index.d.ts @@ -191,8 +191,8 @@ export interface Options { /** * Don't generate records for lines containing empty column values (column matching /\s*\/), defaults to false. */ - skip_lines_with_empty_values?: boolean; - skipLinesWithEmptyValues?: boolean; + skip_records_with_empty_values?: boolean; + skipRecordsWithEmptyValues?: boolean; /** * Stop handling records after the requested number of records. */ diff --git a/packages/csv-parse/lib/index.js b/packages/csv-parse/lib/index.js index 740659e74..b4ff8ffc5 100644 --- a/packages/csv-parse/lib/index.js +++ b/packages/csv-parse/lib/index.js @@ -449,13 +449,13 @@ class Parser extends Transform { }else{ throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(options.skip_empty_lines)}`); } - // Normalize option `skip_lines_with_empty_values` - if(typeof options.skip_lines_with_empty_values === 'boolean'){ + // Normalize option `skip_records_with_empty_values` + if(typeof options.skip_records_with_empty_values === 'boolean'){ // Great, nothing to do - }else if(options.skip_lines_with_empty_values === undefined || options.skip_lines_with_empty_values === null){ - options.skip_lines_with_empty_values = false; + }else if(options.skip_records_with_empty_values === undefined || options.skip_records_with_empty_values === null){ + options.skip_records_with_empty_values = false; }else{ - throw new Error(`Invalid Option: skip_lines_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_lines_with_empty_values)}`); + throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(options.skip_records_with_empty_values)}`); } // Normalize option `skip_lines_with_error` if(typeof options.skip_lines_with_error === 'boolean'){ @@ -860,7 +860,7 @@ class Parser extends Transform { } } __onRecord(){ - const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options; + 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; const {enabled, record} = this.state; if(enabled === false){ return this.__resetRecord(); @@ -868,7 +868,7 @@ class Parser extends Transform { // Convert the first line into column names const recordLength = record.length; if(columns === true){ - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } @@ -909,7 +909,7 @@ class Parser extends Transform { if(finalErr) return finalErr; } } - if(skip_lines_with_empty_values === true && isRecordEmpty(record)){ + if(skip_records_with_empty_values === true && isRecordEmpty(record)){ this.__resetRecord(); return; } diff --git a/packages/csv-parse/samples/option.skip_lines_with_empty_values.js b/packages/csv-parse/samples/option.skip_records_with_empty_values.js similarity index 84% rename from packages/csv-parse/samples/option.skip_lines_with_empty_values.js rename to packages/csv-parse/samples/option.skip_records_with_empty_values.js index c1bfc974b..6d5be4676 100644 --- a/packages/csv-parse/samples/option.skip_lines_with_empty_values.js +++ b/packages/csv-parse/samples/option.skip_records_with_empty_values.js @@ -7,7 +7,7 @@ a,b,c , ,\t d,e,f `.trim(), { - skip_lines_with_empty_values: true + skip_records_with_empty_values: true }, (err, records) => { assert.deepStrictEqual(records, [ ['a', 'b', 'c'], diff --git a/packages/csv-parse/test/api.types.ts b/packages/csv-parse/test/api.types.ts index e9d88d27e..90e4eff5e 100644 --- a/packages/csv-parse/test/api.types.ts +++ b/packages/csv-parse/test/api.types.ts @@ -34,7 +34,7 @@ describe('API Types', () => { 'on_record', 'quote', 'raw', 'record_delimiter', 'relax_column_count', 'relax_column_count_less', 'relax_column_count_more', 'relax_quotes', 'rtrim', 'skip_empty_lines', - 'skip_lines_with_empty_values', 'skip_lines_with_error', 'to', + 'skip_records_with_empty_values', 'skip_lines_with_error', 'to', 'to_line', 'trim' ]) }) @@ -287,10 +287,10 @@ describe('API Types', () => { options.skipEmptyLines = true }) - it('skip_lines_with_empty_values', () => { + it('skip_records_with_empty_values', () => { const options: Options = {} - options.skip_lines_with_empty_values = true - options.skipLinesWithEmptyValues = true + options.skip_records_with_empty_values = true + options.skipRecordsWithEmptyValues = true }) it('skip_lines_with_error', () => { diff --git a/packages/csv-parse/test/option.columns.coffee b/packages/csv-parse/test/option.columns.coffee index f5abec612..e9a58fac8 100644 --- a/packages/csv-parse/test/option.columns.coffee +++ b/packages/csv-parse/test/option.columns.coffee @@ -136,12 +136,12 @@ describe 'Option `columns`', -> ] unless err next err - it 'header detection honors skip_lines_with_empty_values', (next) -> + it 'header detection honors skip_records_with_empty_values', (next) -> parse """ ,, a,b,c 1,2,3 - """, columns: true, skip_lines_with_empty_values: true, (err, records) -> + """, columns: true, skip_records_with_empty_values: true, (err, records) -> records.should.eql [ {a: "1", b: "2", c: "3"} ] unless err diff --git a/packages/csv-parse/test/option.skip_lines_with_empty_values.coffee b/packages/csv-parse/test/option.skip_records_with_empty_values.coffee similarity index 63% rename from packages/csv-parse/test/option.skip_lines_with_empty_values.coffee rename to packages/csv-parse/test/option.skip_records_with_empty_values.coffee index 6cb5c36f8..763b90b8e 100644 --- a/packages/csv-parse/test/option.skip_lines_with_empty_values.coffee +++ b/packages/csv-parse/test/option.skip_records_with_empty_values.coffee @@ -1,19 +1,19 @@ import { parse } from '../lib/index.js' -describe 'Option `skip_lines_with_empty_values`', -> +describe 'Option `skip_records_with_empty_values`', -> it 'validation', -> - parse '', skip_lines_with_empty_values: true, (->) - parse '', skip_lines_with_empty_values: false, (->) - parse '', skip_lines_with_empty_values: null, (->) - parse '', skip_lines_with_empty_values: undefined, (->) + parse '', skip_records_with_empty_values: true, (->) + parse '', skip_records_with_empty_values: false, (->) + parse '', skip_records_with_empty_values: null, (->) + parse '', skip_records_with_empty_values: undefined, (->) (-> - parse '', skip_lines_with_empty_values: 1, (->) - ).should.throw 'Invalid Option: skip_lines_with_empty_values must be a boolean, got 1' + parse '', skip_records_with_empty_values: 1, (->) + ).should.throw 'Invalid Option: skip_records_with_empty_values must be a boolean, got 1' (-> - parse '', skip_lines_with_empty_values: 'oh no', (->) - ).should.throw 'Invalid Option: skip_lines_with_empty_values must be a boolean, got "oh no"' + parse '', skip_records_with_empty_values: 'oh no', (->) + ).should.throw 'Invalid Option: skip_records_with_empty_values must be a boolean, got "oh no"' it 'dont skip by default', (next) -> parse """ @@ -35,7 +35,7 @@ describe 'Option `skip_lines_with_empty_values`', -> , IJK,LMN , - """, skip_lines_with_empty_values: true, (err, records) -> + """, skip_records_with_empty_values: true, (err, records) -> return next err if err records.should.eql [ [ 'ABC', 'DEF' ] @@ -49,7 +49,7 @@ describe 'Option `skip_lines_with_empty_values`', -> \t , \t IJK,LMN \t , \t - """, skip_lines_with_empty_values: true, (err, records) -> + """, skip_records_with_empty_values: true, (err, records) -> return next err if err records.should.eql [ [ 'ABC', 'DEF' ] @@ -65,7 +65,7 @@ describe 'Option `skip_lines_with_empty_values`', -> null undefined """, - skip_lines_with_empty_values: true + skip_records_with_empty_values: true cast: (value) -> switch value when 'empty_buffer' then Buffer.from ''