From: Ardis Lu Date: Sat, 18 Jan 2025 07:18:03 +0000 (-0800) Subject: Split out TransformationInput and TransformationOutput types X-Git-Tag: v0.1.0~120 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=f0b1eba640d282d4319450f221892894613ed645;p=csvio Split out TransformationInput and TransformationOutput types --- diff --git a/src/core.js b/src/core.js index e7d7978..f25b3cd 100644 --- a/src/core.js +++ b/src/core.js @@ -127,11 +127,21 @@ export function createCSVReadableStream(path) { })); } +/** + * A row of input CSV data. + * @typedef {Array|string} TransformationInput + */ + +/** + * A row or rows of output CSV data, or null to skip a row. + * @typedef {Array>|Array|string|null} TransformationOutput + */ + /** * A function to process a row of CSV data from `createCSVReadableStream`. * @callback TransformationFunction - * @param {Array|string} row A row of input CSV data. - * @returns {Array>|Array|string|null} A row or rows of output CSV data, or null to skip a row. + * @param {TransformationInput} row + * @returns {TransformationOutput} */ /** @@ -145,9 +155,9 @@ export function createCSVReadableStream(path) { * using `JSON.parse()` before being sent to `fn()`. The default value is `false`. * @property {boolean} [rawOutput=false] Set to `true` to send the raw return value of `fn()` to the next stream. Otherwise, the return value of * `fn()` will be serialized using `JSON.stringify()` before being sent to the next stream. The default value is `false`. - * @property {null|function(Array|string,Error,TransformationFunction):Array>|Array|string|null} [onError=null] - * Set to a function to catch errors thrown by the transformation function. The CSV row, the error that was thrown, and the transformation function - * itself will be passed to the `onError` function. The default value is `null` (errors will not be caught). + * @property {null|function(TransformationInput,Error,TransformationFunction):TransformationOutput} [onError=null] Set to a function to catch + * errors thrown by the transformation function. The input data, the error that was thrown, and the transformation function itself will be passed + * to the `onError` function. The default value is `null` (errors will not be caught). */ /**