]> git.ardis.lu - csvio/commitdiff
Refine types
authorArdis Lu <ardisglu@gmail.com>
Tue, 27 May 2025 05:06:37 +0000 (22:06 -0700)
committerArdis Lu <ardisglu@gmail.com>
Tue, 27 May 2025 05:06:37 +0000 (22:06 -0700)
src/core.js
src/normalization.js
test/normalization.test.js

index b193f4060819ccce020fa5c12cac975e53000c14..e7454d6ff19e402b88db5e5c1befe8271dd449cb 100644 (file)
@@ -1,6 +1,7 @@
 import { mkdir, open } from 'node:fs/promises';
 import { dirname, basename, normalize } from 'node:path';
 import { fileURLToPath } from 'node:url';
+import { ReadableStream, WritableStream, TransformStream } from 'node:stream/web';
 /** @import { PathLike } from 'node:fs'; */
 /** @import { FileHandle } from 'node:fs/promises'; */
 
index 9092d0b0092dfcce26e27b9ca012176d032d140c..f1428437cdc8a4bb8d91da2c6ade8582cfbde178 100644 (file)
@@ -1,3 +1,5 @@
+import { TransformStream } from 'node:stream/web';
+
 // User locale's decimal separator
 const DECIMAL_SEPARATOR = Intl.NumberFormat().formatToParts(.1).find(p => p.type === 'decimal').value;
 
@@ -23,7 +25,7 @@ export function toCamelCase(str) {
  * Convert scientific notation ("E" notation) to normal form.
  * 
  * @param {string} str A string representing a number expressed using scientific notation (e.g., `"1E+18"`).
- * @param {boolean} truncate If `true`, decimals will be truncated in the expanded string. Defaults to `false`.
+ * @param {boolean} [truncate=false] If `true`, decimals will be truncated in the expanded string. Defaults to `false`.
  * @returns {string} A string representing the normal form of the number (e.g., `"1000000000000000000"`).
  * @throws {TypeError} If `str` is not a `string`, a `TypeError` will be thrown.
  * @throws {SyntaxError} If `str` is not valid scientific notation, a `SyntaxError` will be thrown.
index 92b8fe30c0c37b6b41c903a0561e892f98212910..4ca8e494757a07113df8e700b6f49eb90dd9d4a7 100644 (file)
@@ -265,7 +265,9 @@ suite('CSVNormalizer', { concurrency: true }, () => {
       ['a', 'b']
     ])
       .pipeThrough(new CSVNormalizer([
+        // @ts-expect-error
         { name: 'columnA', type: 'abc' },
+        // @ts-expect-error
         { name: 'columnB', type: 'def' }
       ]))
       .pipeThrough(new CSVDenormalizer())
@@ -279,10 +281,10 @@ suite('CSVNormalizer', { concurrency: true }, () => {
 suite('CSVNormalizer and CSVDenormalizer end-to-end', { concurrency: true }, () => {
   test('can normalize', { concurrency: true }, async () => {
     const headers = [
-      { name: 'stringCol', displayName: 'String Column', type: 'string', defaultValue: 'N/A' },
-      { name: 'numberCol', displayName: 'Number Column', type: 'number' },
-      { name: 'bigintCol', displayName: 'BigInt Column', type: 'bigint' },
-      { name: 'dateCol', displayName: 'Date Column', type: 'date' }
+      /** @type {const} */({ name: 'stringCol', displayName: 'String Column', type: 'string', defaultValue: 'N/A' }),
+      /** @type {const} */({ name: 'numberCol', displayName: 'Number Column', type: 'number' }),
+      /** @type {const} */({ name: 'bigintCol', displayName: 'BigInt Column', type: 'bigint' }),
+      /** @type {const} */({ name: 'dateCol', displayName: 'Date Column', type: 'date' })
     ]
     await new CSVReader('./test/data/normalization.csv')
       .pipeThrough(new CSVNormalizer(headers))
This page took 0.058513 seconds and 4 git commands to generate.