From: Ardis Lu Date: Mon, 27 Oct 2025 05:52:12 +0000 (-0700) Subject: Update type to allow `Promise>` return value X-Git-Tag: v0.1.9~5 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=f8e3eb34bb9d142f6d48aa71794fb48c8317c3f9;p=csvio Update type to allow `Promise>` return value --- 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>} */ /**