]> git.ardis.lu - csvio/commitdiff
Update type to allow `Promise<ReadableStream<TransformationOutput>>` return value
authorArdis Lu <ardisglu@gmail.com>
Mon, 27 Oct 2025 05:52:12 +0000 (22:52 -0700)
committerArdis Lu <ardisglu@gmail.com>
Mon, 27 Oct 2025 05:52:12 +0000 (22:52 -0700)
src/core.js

index 84900991c9580109a4d5be3acf203b45a544095e..be55c12e92f6fa2603c5bdfea5341160a91315e1 100644 (file)
@@ -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<T>} MaybePromise
+ */
+
 /**
  * A row or rows of output CSV data, or `null` to not output anything.
  * @typedef {Array<Array<any>>|Array<any>|ArrayLike<any>|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<any>} row A row of input CSV data before transformation.
- * @returns {TransformationOutput|Promise<TransformationOutput>|ReadableStream<TransformationOutput>}
+ * @returns {MaybePromise<TransformationOutput|ReadableStream<TransformationOutput>>}
  */
 
 /**
  * A function to process multiple rows of CSV data from `CSVReader`.
  * @callback TransformationFunctionBatch
  * @param {Array<Array<any>>} rows Multiple rows of input CSV data.
- * @returns {TransformationOutput|Promise<TransformationOutput>|ReadableStream<TransformationOutput>}
+ * @returns {MaybePromise<TransformationOutput|ReadableStream<TransformationOutput>>}
  */
 
 /**
@@ -240,7 +246,7 @@ export class CSVReader {
  * @param {Array<any>} 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<TransformationOutput>|ReadableStream<TransformationOutput>}
+ * @returns {MaybePromise<TransformationOutput|ReadableStream<TransformationOutput>>}
  */
 
 /**
@@ -249,7 +255,7 @@ export class CSVReader {
  * @param {Array<Array<any>>} 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<TransformationOutput>|ReadableStream<TransformationOutput>}
+ * @returns {MaybePromise<TransformationOutput|ReadableStream<TransformationOutput>>}
  */
 
 /**
This page took 0.054386 seconds and 4 git commands to generate.