From: Ardis Lu Date: Sat, 16 Aug 2025 06:13:09 +0000 (-0700) Subject: Loosen `CSVNormalizerRow` type to match `CSVDenormalizer` usage X-Git-Tag: v0.1.5~6 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=914b0fb37388b92761f6453635f9179da57c60ae;p=csvio Loosen `CSVNormalizerRow` type to match `CSVDenormalizer` usage --- diff --git a/src/normalization.js b/src/normalization.js index 0432288..519d3f9 100644 --- a/src/normalization.js +++ b/src/normalization.js @@ -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>} */ + /** @type {import('node:stream/web').TransformerTransformCallback,Array>>} */ #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} */ + /** @type {Array>} */ const out = []; for (const { name, type, displayName, defaultValue, index } of this.#columns) { let value = chunk[index] ?? '';