]> git.ardis.lu - csvio/commitdiff
Improve JSDoc type import consistency
authorArdis Lu <ardisglu@gmail.com>
Sat, 27 Sep 2025 06:06:44 +0000 (23:06 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 27 Sep 2025 06:06:44 +0000 (23:06 -0700)
src/core.js
src/errorStrategies.js
src/normalization.js
test/utils.js

index 5d35eee91523facca11e089a98c01a2f4de5f648..9eec4219796db6d2f2e21c5c8adadaba77abbc0c 100644 (file)
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
 import { ReadableStream, WritableStream, TransformStream, TextDecoderStream } from 'node:stream/web';
 /** @import { PathLike } from 'node:fs'; */
 /** @import { FileHandle } from 'node:fs/promises'; */
+/** @import { TransformerFlushCallback, TransformerTransformCallback } from 'node:stream/web'; */
 
 /**
  * Parse and normalize a `PathLike` object into a string.
@@ -154,7 +155,7 @@ export class CSVReader {
     return createProxy(this, stream);
   }
 
-  /** @type {import('node:stream/web').TransformerTransformCallback<string,Array<string>>} */
+  /** @type {TransformerTransformCallback<string,Array<string>>} */
   #transform(chunk, controller) {
     for (const char of chunk) {
       /* Escape mode logic */
@@ -202,7 +203,7 @@ export class CSVReader {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerFlushCallback<Array<string>>} */
+  /** @type {TransformerFlushCallback<Array<string>>} */
   #flush(controller) {
     if (this.#field !== '' || this.#row.length !== 0) { // CSV terminated without a trailing CRLF, leaving a row in the queue
       this.#row.push(this.#field); // Last field is always un-pushed if CSV terminated with nothing
@@ -392,7 +393,7 @@ export class CSVTransformer extends TransformStream {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<string>>} */
+  /** @type {TransformerTransformCallback<Array<string>,Array<string>>} */
   async #transform(chunk, controller) {
     // If row is an array of objects, then the transformation has "normalized" the data and there is no header row.
     // Instead, the header data has been incorporated into the object keys. The transformation is responsible
@@ -424,7 +425,7 @@ export class CSVTransformer extends TransformStream {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerFlushCallback<Array<string>>} */
+  /** @type {TransformerFlushCallback<Array<string>>} */
   async #flush(controller) {
     if (this.#batch.length > 0) {
       this.#concurrent.push(this.#wrappedFn(this.#batch));
index 1a1fe2bdfe9ab76f92889fee0a4e9cfb661bc9aa..354a47ac643b0be5d9d9ed6ee8416a682520c971 100644 (file)
@@ -1,6 +1,5 @@
 import { setTimeout } from 'node:timers/promises';
-
-/** @import {TransformationErrorFunction} from './core.js'; */
+/** @import { TransformationErrorFunction } from './core.js'; */
 
 /**
  * A wrapper around `node:timers/promises`'s async `setTimeout`. This wrapper is required to mock for testing purposes.
index dbba4b34649f70c58c3bef4a80b91645efd7828f..3d51af710019753a9cba1e36de94bb10ab5c480a 100644 (file)
@@ -1,4 +1,5 @@
 import { TransformStream } from 'node:stream/web';
+/** @import { TransformerTransformCallback } from 'node:stream/web'; */
 
 /**
  * Get the decimal separator character to parse numbers formatted in different locales.
@@ -143,7 +144,7 @@ export class CSVNormalizer extends TransformStream {
     }
   }
 
-  /** @type {import('node:stream/web').TransformerTransformCallback<Array<string>,Array<Required<CSVNormalizerField>>>} */
+  /** @type {TransformerTransformCallback<Array<string>,Array<Required<CSVNormalizerField>>>} */
   #transform(chunk, controller) {
     // Assume first non-empty row is headers and use it to prepare the columns object
     // Note: the headers row is NOT forwarded downstream
@@ -318,7 +319,7 @@ export class CSVDenormalizer extends TransformStream {
   constructor() {
     let firstRow = true;
     super({
-      /** @type {import('node:stream/web').TransformerTransformCallback<Array<CSVNormalizerField>,Array<string>>} */
+      /** @type {TransformerTransformCallback<Array<CSVNormalizerField>,Array<string>>} */
       transform(chunk, controller) {
         if (firstRow) {
           firstRow = false;
index 02ec5b63e40590d6b8c4376a8c575c6b4a15d508..fe1b9407c780a9b61ea4bdca550b60c1252abccd 100644 (file)
@@ -5,7 +5,6 @@ import { normalize } from 'node:path';
 import { ReadableStream } from 'node:stream/web';
 /** @import { TestContext } from 'node:test'; */
 /** @import { PathLike } from 'node:fs'; */
-/** @import { FileHandle } from 'node:fs/promises'; */
 
 import { utils } from '../src/errorStrategies.js';
 
This page took 0.067583 seconds and 4 git commands to generate.