From f8e3eb34bb9d142f6d48aa71794fb48c8317c3f9 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 26 Oct 2025 22:52:12 -0700 Subject: [PATCH] Update type to allow `Promise>` return value --- src/core.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index 8490099..be55c12 100644 --- a/src/core.js +++ b/src/core.js @@ -215,6 +215,12 @@ export class CSVReader { } } +/** + * A type that may either be a value or a `Promise` resolving to that value. + * @template T + * @typedef {T|Promise} MaybePromise + */ + /** * A row or rows of output CSV data, or `null` to not output anything. * @typedef {Array>|Array|ArrayLike|string|null} TransformationOutput @@ -224,14 +230,14 @@ export class CSVReader { * A function to process a row of CSV data from `CSVReader`. * @callback TransformationFunction * @param {Array} row A row of input CSV data before transformation. - * @returns {TransformationOutput|Promise|ReadableStream} + * @returns {MaybePromise>} */ /** * A function to process multiple rows of CSV data from `CSVReader`. * @callback TransformationFunctionBatch * @param {Array>} rows Multiple rows of input CSV data. - * @returns {TransformationOutput|Promise|ReadableStream} + * @returns {MaybePromise>} */ /** @@ -240,7 +246,7 @@ export class CSVReader { * @param {Array} row The row passed to the transformation function which threw the error. * @param {Error} error The error thrown by the transformation function. * @param {TransformationFunction} fn The transformation function itself. This argument can be used to retry a transformation. - * @returns {TransformationOutput|Promise|ReadableStream} + * @returns {MaybePromise>} */ /** @@ -249,7 +255,7 @@ export class CSVReader { * @param {Array>} rows The rows of input CSV data passed to the transformation function which threw the error. * @param {Error} error The error thrown by the transformation function. * @param {TransformationFunctionBatch} fn The transformation function itself. This argument can be used to retry a transformation. - * @returns {TransformationOutput|Promise|ReadableStream} + * @returns {MaybePromise>} */ /** -- 2.47.3