]> git.ardis.lu - csvio/commitdiff
Rename `CSVNormalizerRow` to `CSVNormalizerField`
authorArdis Lu <ardisglu@gmail.com>
Fri, 22 Aug 2025 02:36:54 +0000 (19:36 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 22 Aug 2025 02:36:54 +0000 (19:36 -0700)
This type is not a row of data, it is a single field. So the name "row" never made sense.

README.md
src/index.js
src/normalization.js

index 1815a70136c03520d197aff580836444b1d7e134..46ae6ccbf0178b42bbf7478120e97278593a38c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -163,9 +163,9 @@ In addition to the core API, optional utilities are provided to address common C
 - **Fix date and number mangling**: Spreadsheet programs may [automatically cast data types in unexpected ways](https://www.theverge.com/2020/8/6/21355674/human-genes-rename-microsoft-excel-misreading-dates). `CSVNormalizer` will perform various transformations to reverse data type casting that was unlikely to be intentional.
 - **Flexible column naming**: Column names are normalized to camelCase to prevent issues with subtly inconsistent names (e.g., `Column A`, `column A`, and `ColumnA` are all considered to be the same name).
 - **Column ordering**: Columns may appear in any order on the input CSV. The columns in the output are re-ordered to match the order in the `CSVNormalizerHeader` array.
-- **Stream of objects**: The stream is transformed from an `Array<string>` to an `Array<CSVNormalizerRow>` to provide a better developer experience for subsequent transformations.
+- **Stream of objects**: The stream is transformed from an `Array<string>` to an `Array<CSVNormalizerField>` to provide a better developer experience for subsequent transformations.
 
-`CSVDenormalizer` is a `TransformStream` that will convert an `Array<CSVNormalizerRow>` created by `CSVNormalizer` back into an `Array<string>`, ready for writing to a file.
+`CSVDenormalizer` is a `TransformStream` that will convert an `Array<CSVNormalizerField>` created by `CSVNormalizer` back into an `Array<string>`, ready for writing to a file.
 
 ```javascript
 import { CSVNormalizer, CSVDenormalizer } from '@ardislu/csvio';
index c7c21350bd677cf607b2564ec261e97781dc96c6..757d2712ee4ac23aeb867ff8c6b17772a93af3de 100644 (file)
@@ -13,6 +13,6 @@ export { ErrorStrategies } from './errorStrategies.js';
 /** @typedef {import('./core.js').CSVWriterStatus} CSVWriterStatus */
 /** @typedef {import('./normalization.js').CSVNormalizerHeader} CSVNormalizerHeader */
 /** @typedef {import('./normalization.js').CSVNormalizerOptions} CSVNormalizerOptions */
-/** @typedef {import('./normalization.js').CSVNormalizerRow} CSVNormalizerRow */
+/** @typedef {import('./normalization.js').CSVNormalizerField} CSVNormalizerField */
 /** @typedef {import('./errorStrategies.js').RetryOptions} RetryOptions */
 /** @typedef {import('./errorStrategies.js').BackoffOptions} BackoffOptions */
index 519d3f9e83b0a22eccfc1aa9df9d4a505dd56a07..5b2304e08d60e6addc2f2add9be7fd8d36bddd81 100644 (file)
@@ -91,7 +91,7 @@ export function expandScientificNotation(str, truncate = false) {
 
 /**
  * The output of `CSVNormalizer`.
- * @typedef {Object} CSVNormalizerRow
+ * @typedef {Object} CSVNormalizerField
  * @property {string} name The column name after normalization to camelCase.
  * @property {string} [displayName] The desired column name in the output CSV.
  * @property {string|number} value The value of the field after attempted data casting. If the original field was empty, this value
@@ -143,7 +143,7 @@ export class CSVNormalizer extends TransformStream {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<Required<CSVNormalizerRow>>>} */
+  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<Required<CSVNormalizerField>>>} */
   #transform(chunk, controller) {
     // Assume first row is headers and use it to prepare the columns object
     // Note: the headers row is NOT forwarded downstream
@@ -162,7 +162,7 @@ export class CSVNormalizer extends TransformStream {
       return;
     }
 
-    /** @type {Array<Required<CSVNormalizerRow>>} */
+    /** @type {Array<Required<CSVNormalizerField>>} */
     const out = [];
     for (const { name, type, displayName, defaultValue, index } of this.#columns) {
       let value = chunk[index] ?? '';
@@ -299,14 +299,14 @@ export class CSVNormalizer extends TransformStream {
 }
 
 /**
- * A `TransformStream` to transform a `CSVNormalizerRow` into an array that can be converted to CSV data.
+ * A `TransformStream` to transform a `Array<CSVNormalizerField>` into an array that can be converted to CSV data.
  * @extends TransformStream
  */
 export class CSVDenormalizer extends TransformStream {
   constructor() {
     let firstRow = true;
     super({
-      /** @type {import('node:stream/web').TransformerTransformCallback<Array<CSVNormalizerRow>,Array<string>>} */
+      /** @type {import('node:stream/web').TransformerTransformCallback<Array<CSVNormalizerField>,Array<string>>} */
       transform(chunk, controller) {
         if (firstRow) {
           firstRow = false;
This page took 0.042576 seconds and 4 git commands to generate.