]> git.ardis.lu - csvio/commitdiff
Loosen `CSVNormalizerRow` type to match `CSVDenormalizer` usage
authorArdis Lu <ardisglu@gmail.com>
Sat, 16 Aug 2025 06:13:09 +0000 (23:13 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 16 Aug 2025 06:13:09 +0000 (23:13 -0700)
src/normalization.js

index 0432288d6253c8092f6708054a1fdc7dc49cfd16..519d3f9e83b0a22eccfc1aa9df9d4a505dd56a07 100644 (file)
@@ -93,10 +93,10 @@ export function expandScientificNotation(str, truncate = false) {
  * The output of `CSVNormalizer`.
  * @typedef {Object} CSVNormalizerRow
  * @property {string} name The column name after normalization to camelCase.
- * @property {string} displayName The desired column name in the output CSV.
+ * @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
  * is set to the provided `defaultValue` or `''` (empty string) if no `defaultValue` was provided.
- * @property {boolean} emptyField Boolean to indicate whether the original field was empty.
+ * @property {boolean} [emptyField] Boolean to indicate whether the original field was empty.
  */
 
 /**
@@ -143,7 +143,7 @@ export class CSVNormalizer extends TransformStream {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<CSVNormalizerRow>>} */
+  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<Required<CSVNormalizerRow>>>} */
   #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<CSVNormalizerRow>} */
+    /** @type {Array<Required<CSVNormalizerRow>>} */
     const out = [];
     for (const { name, type, displayName, defaultValue, index } of this.#columns) {
       let value = chunk[index] ?? '';
This page took 0.036724 seconds and 4 git commands to generate.