]> git.ardis.lu - csvio/log
csvio
13 months agoBroaden `value` type to `any`
Ardis Lu [Sun, 24 Aug 2025 04:29:29 +0000 (21:29 -0700)]
Broaden `value` type to `any`

13 months agoAdd note on long release notes
Ardis Lu [Sun, 24 Aug 2025 04:26:39 +0000 (21:26 -0700)]
Add note on long release notes

13 months agoAdd example for `stdin` and `stdout` usage
Ardis Lu [Fri, 22 Aug 2025 03:27:37 +0000 (20:27 -0700)]
Add example for `stdin` and `stdout` usage

13 months agoRename `CSVNormalizerRow` to `CSVNormalizerField`
Ardis Lu [Fri, 22 Aug 2025 02:36:54 +0000 (19:36 -0700)]
Rename `CSVNormalizerRow` to `CSVNormalizerField`

This type is not a row of data, it is a single field. So the name "row" never made sense.

13 months agoRemove platform-specific data from test gzip file
Ardis Lu [Wed, 20 Aug 2025 07:14:44 +0000 (00:14 -0700)]
Remove platform-specific data from test gzip file

This step is not required for real-world usage, but for testing purposes it is useful to share the same tests and test data across platforms.

14 months agoCut v0.1.5 v0.1.5
Ardis Lu [Mon, 18 Aug 2025 04:11:15 +0000 (21:11 -0700)]
Cut v0.1.5

14 months agoAdd `types:check` script mentioned in `CONTRIBUTING.md`
Ardis Lu [Mon, 18 Aug 2025 03:15:31 +0000 (20:15 -0700)]
Add `types:check` script mentioned in `CONTRIBUTING.md`

14 months agoUpgrade dependencies
Ardis Lu [Mon, 18 Aug 2025 03:14:24 +0000 (20:14 -0700)]
Upgrade dependencies

14 months agoAdd test case for raw strings passed to `TransformStream` CSVWriter
Ardis Lu [Mon, 18 Aug 2025 03:08:26 +0000 (20:08 -0700)]
Add test case for raw strings passed to `TransformStream` CSVWriter

14 months agoAdd initial `TransformStream` CSVWriter implementation
Ardis Lu [Sun, 17 Aug 2025 06:40:55 +0000 (23:40 -0700)]
Add initial `TransformStream` CSVWriter implementation

This change enables users to create a `TransformStream` by doing `new CSVWriter()` instead of always creating an ultimate sink `WritableStream`. This behavior is useful when there is some transformation that must be performed on the CSV data before writing (e.g., compressing into a `.csv.gz` file using `CompressionStream`).

14 months agoDelete unused import
Ardis Lu [Sun, 17 Aug 2025 05:42:08 +0000 (22:42 -0700)]
Delete unused import

14 months agoLoosen `CSVNormalizerRow` type to match `CSVDenormalizer` usage
Ardis Lu [Sat, 16 Aug 2025 06:13:09 +0000 (23:13 -0700)]
Loosen `CSVNormalizerRow` type to match `CSVDenormalizer` usage

14 months agoAdd contribution checklist
Ardis Lu [Mon, 11 Aug 2025 06:42:42 +0000 (23:42 -0700)]
Add contribution checklist

14 months agoFix bug where it was not possible to read into an ArrayBuffer with offset
Ardis Lu [Wed, 6 Aug 2025 04:38:51 +0000 (21:38 -0700)]
Fix bug where it was not possible to read into an ArrayBuffer with offset

The code was originally correct because it was copied from the Streams specification [1], but turned incorrect after copying from Node.js's implementation [2], and now reverted back to the original correct implementation.

[1] https://streams.spec.whatwg.org/#example-rbs-pull
[2] https://github.com/nodejs/node/blob/134625d76139b4b3630d5baaf2efccae01ede564/lib/internal/fs/promises.js#L322

14 months agoDelete unnecessary negative test
Ardis Lu [Tue, 5 Aug 2025 06:50:42 +0000 (23:50 -0700)]
Delete unnecessary negative test

The row length check in `csvStreamEqualWritable` now covers the original testing edge case that necessitated the negative test. Now the test will correctly fail without requiring the negative test to trigger the failure.

14 months agoFix broken test
Ardis Lu [Tue, 5 Aug 2025 06:45:11 +0000 (23:45 -0700)]
Fix broken test

14 months agoFix `createProxy` type templates
Ardis Lu [Tue, 5 Aug 2025 06:13:47 +0000 (23:13 -0700)]
Fix `createProxy` type templates

14 months agoRemove intermediate JSON serialization and `rawInput`/`rawOutput` options
Ardis Lu [Mon, 4 Aug 2025 06:06:34 +0000 (23:06 -0700)]
Remove intermediate JSON serialization and `rawInput`/`rawOutput` options

Previously, each row was JSON serialized and deserialized on each `.pipeThrough`. The intent of this serialization was to normalize the data of each row, with an escape hatch in the `rawInput` and `rawOutput` options.

However, this approach is counterintuitive because most users would expect a CSV row to simply be an `Array<string>`, NOT a `string` that can be `JSON.parse`-ed into an `Array<string>`. Furthermore, this excessive serialization has a significant performance impact. Lastly, the `rawInput` and `rawOutput` options effectively made `CSVTransformer` an overly complex and difficult-to-use JSON parser on top of a CSV transformer.

So, simply removing the JSON serialization and directly enqueuing the actual object (i.e., the `Array<string>`) resolves all these issues with minimal impact to the user-facing API.

14 months agoFix words
Ardis Lu [Mon, 4 Aug 2025 01:52:53 +0000 (18:52 -0700)]
Fix words

14 months agoAdd npm script to create local dev packages
Ardis Lu [Sat, 2 Aug 2025 07:21:13 +0000 (00:21 -0700)]
Add npm script to create local dev packages

14 months agoAdd initial `TransformStream` CSVReader implementation
Ardis Lu [Wed, 30 Jul 2025 06:53:47 +0000 (23:53 -0700)]
Add initial `TransformStream` CSVReader implementation

This change enables users to create a `TransformStream` by doing `new CSVReader()` instead of always creating an underlying source `ReadableStream`. This behavior is useful when there is some transformation that must be performed on the source file before parsing (e.g., decompressing a `.csv.gz` file using `DecompressionStream`).

14 months agoAdd tests for `instanceof` behavior
Ardis Lu [Tue, 29 Jul 2025 06:35:40 +0000 (23:35 -0700)]
Add tests for `instanceof` behavior

In preparation for possible future refactoring for these classes to return a `Proxy` object (this pattern is required to simulate dynamic superclasses, e.g., `CSVReader` returning either `ReadableStream` OR `TransformStream` depending on constructor argument). If such refactoring takes place, these tests will check that `Proxy` was implemented correctly and maintain backwards compatibility.

15 months agoAdd initial tests for memory leaks
Ardis Lu [Tue, 15 Jul 2025 05:07:56 +0000 (22:07 -0700)]
Add initial tests for memory leaks

Future tests should be dedicated for finding memory leaks only, but as an initial step it makes sense to add a simple sanity check to the large file tests.

15 months agoCut v0.1.4 v0.1.4
Ardis Lu [Mon, 14 Jul 2025 04:41:15 +0000 (21:41 -0700)]
Cut v0.1.4

15 months agoUpgrade dependencies
Ardis Lu [Mon, 14 Jul 2025 04:40:27 +0000 (21:40 -0700)]
Upgrade dependencies

15 months agoDelete redundant BOM check
Ardis Lu [Sun, 13 Jul 2025 05:44:16 +0000 (22:44 -0700)]
Delete redundant BOM check

`TextDecoderStream` already handles it upstream, no need to check for it again.

15 months agoSimplify implementation
Ardis Lu [Sun, 13 Jul 2025 05:30:53 +0000 (22:30 -0700)]
Simplify implementation

15 months agoUse consistent JSDoc typecasting formatting
Ardis Lu [Sun, 13 Jul 2025 05:04:31 +0000 (22:04 -0700)]
Use consistent JSDoc typecasting formatting

15 months agoAdd initial documentation for `CSVNormalizer`
Ardis Lu [Sun, 13 Jul 2025 04:47:52 +0000 (21:47 -0700)]
Add initial documentation for `CSVNormalizer`

15 months agoRe-export callback types
Ardis Lu [Sat, 12 Jul 2025 06:22:50 +0000 (23:22 -0700)]
Re-export callback types

These types were initially missed because they are defined with the `callback` annotation and not `typedef`. For future completeness, search for `export type` in the generated declaration files.

15 months agoAdd `useLiteralNames` option to disable column name normalization
Ardis Lu [Sat, 12 Jul 2025 05:09:25 +0000 (22:09 -0700)]
Add `useLiteralNames` option to disable column name normalization

This behavior is useful to preserve data when an input CSV has multiple columns with the same normalized name. By default, `CSVNormalizer` will remove these duplicate columns (the data from the last column is used).

Note that columns with the same *literal* name are still removed even when `useLiteralNames` is `true`. If you need to preserve columns with the same literal name, use a lower-level transformation (e.g., `CSVTransformer`).

15 months agoAdd explicit test for `passthroughEmptyRows`
Ardis Lu [Sat, 12 Jul 2025 04:55:20 +0000 (21:55 -0700)]
Add explicit test for `passthroughEmptyRows`

15 months agoRe-export all types in `index.js`
Ardis Lu [Fri, 11 Jul 2025 04:49:00 +0000 (21:49 -0700)]
Re-export all types in `index.js`

Currently, the types are accessible internally in the library and within `index.js`, but NOT accessible from consumers importing from the `index.js` file. A re-export is required to make the types accessible to end-users.

Additionally, the JSDoc import will only work for types declared at the module scope, so `CSVWriterStatus` was moved to the outer scope.

15 months agoCut v0.1.3 v0.1.3
Ardis Lu [Thu, 10 Jul 2025 06:31:34 +0000 (23:31 -0700)]
Cut v0.1.3

15 months agoUpgrade dependencies
Ardis Lu [Thu, 10 Jul 2025 06:30:14 +0000 (23:30 -0700)]
Upgrade dependencies

15 months agoFix bug where `defaultValue` was not set if row is uneven
Ardis Lu [Thu, 10 Jul 2025 06:11:45 +0000 (23:11 -0700)]
Fix bug where `defaultValue` was not set if row is uneven

15 months agoAdd explicit test for sparse CSV
Ardis Lu [Thu, 10 Jul 2025 06:07:03 +0000 (23:07 -0700)]
Add explicit test for sparse CSV

15 months agoDelete debugging flag
Ardis Lu [Thu, 10 Jul 2025 05:48:36 +0000 (22:48 -0700)]
Delete debugging flag

15 months agoAdd an example for `CSVTransformer` interaction with `CSVNormalizer`
Ardis Lu [Thu, 10 Jul 2025 05:35:32 +0000 (22:35 -0700)]
Add an example for `CSVTransformer` interaction with `CSVNormalizer`

15 months agoSimplify type annotation
Ardis Lu [Thu, 10 Jul 2025 05:31:41 +0000 (22:31 -0700)]
Simplify type annotation

15 months agoIgnore `handleHeaders` if the row has been normalized
Ardis Lu [Thu, 10 Jul 2025 05:10:20 +0000 (22:10 -0700)]
Ignore `handleHeaders` if the row has been normalized

This behavior is desirable when `CSVTransformer` interacts with `CSVNormalizer` or any other transformation which converts the row from `Array<string>` into `Array<Object>`, because it avoids the need to pass `handleHeaders: true` to `CSVTransformer` (which is counterintuitive). It is more accurate to say the header row has been deleted by the transformation and must by re-inserted into the write stream later.

The loosening of the type checking is not a breaking change. Since the row is passed directly to `JSON.parse()`, the fields could have always been type `Object` instead of `string`.

15 months agoFall back on `name` if `displayName` is undefined
Ardis Lu [Thu, 10 Jul 2025 04:33:12 +0000 (21:33 -0700)]
Fall back on `name` if `displayName` is undefined

This behavior is useful when passing rows to `CSVDenormalizer` after a transformation *other* than `CSVNormalizer` (which automatically creates `displayName`).

15 months agoSet default normalization type to `'string'`
Ardis Lu [Thu, 10 Jul 2025 04:12:44 +0000 (21:12 -0700)]
Set default normalization type to `'string'`

This behavior is helpful to perform minimal normalization tasks but otherwise preserve the default CSV transformation behavior (i.e., have all input values be a string).

This is not a breaking change. Previously, `type` would also default to `'string'` after logging a warning in console.

15 months agoFix bug where extra normalization headers were not dropped
Ardis Lu [Wed, 9 Jul 2025 05:42:01 +0000 (22:42 -0700)]
Fix bug where extra normalization headers were not dropped

This bug was not caught due to a separate bug in the test logic, which is also fixed in this commit.

15 months agoAdd explicit test to remove extra headers
Ardis Lu [Wed, 9 Jul 2025 05:22:24 +0000 (22:22 -0700)]
Add explicit test to remove extra headers

15 months agoSort keys to match default order in 5.9
Ardis Lu [Wed, 9 Jul 2025 04:25:22 +0000 (21:25 -0700)]
Sort keys to match default order in 5.9

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-beta/

15 months agoDelete unnecessary constructor annotation
Ardis Lu [Wed, 9 Jul 2025 04:08:14 +0000 (21:08 -0700)]
Delete unnecessary constructor annotation

This tag has no impact on the generated `.d.ts` file so it can be removed.

15 months agoCut v0.1.2 v0.1.2
Ardis Lu [Sun, 6 Jul 2025 02:52:38 +0000 (19:52 -0700)]
Cut v0.1.2

15 months agoUpgrade dependencies
Ardis Lu [Sun, 6 Jul 2025 02:16:20 +0000 (19:16 -0700)]
Upgrade dependencies

15 months agoSupport ArrayLike outputs
Ardis Lu [Sun, 6 Jul 2025 02:14:40 +0000 (19:14 -0700)]
Support ArrayLike outputs

Could be useful for chained transformations using DOM APIs, e.g. passing through the NodeList object.

15 months agoImprove internal type documentation
Ardis Lu [Sat, 5 Jul 2025 01:50:00 +0000 (18:50 -0700)]
Improve internal type documentation

15 months agoIncrease `highWaterMark` for `CSVWriter`'s queuing strategy
Ardis Lu [Fri, 4 Jul 2025 05:02:25 +0000 (22:02 -0700)]
Increase `highWaterMark` for `CSVWriter`'s queuing strategy

This change improves the 100MB Write benchmark from ~9s to ~7s.

Bumping `highWaterMark` to >1 also changes the stream's interaction with `AbortController`, so now the chunk processed during an abort is included in the write.

I believe this behavior has to do with the task queue order of the callback for the `AbortSignal`'s `abort` event - so now with multiple chunks in the queue, the last chunk is written before the `abort` event is processed. I was unable to force this writing code to occur after the `abort` event in a deterministic way.

This situation is a rare edge case so letting it through.

15 months agoSimplify and harden tick indicator
Ardis Lu [Fri, 4 Jul 2025 03:45:55 +0000 (20:45 -0700)]
Simplify and harden tick indicator

Relying on physical timing is flaky (e.g., it will fail if executing on a slow machine).  Sending a simple `tick` increment into the task queue is more reliable.

15 months agoTweak wording
Ardis Lu [Thu, 3 Jul 2025 06:53:31 +0000 (23:53 -0700)]
Tweak wording

15 months agoAdd test to remove empty columns
Ardis Lu [Thu, 3 Jul 2025 06:48:17 +0000 (23:48 -0700)]
Add test to remove empty columns

15 months agoHandle whitespace strings
Ardis Lu [Thu, 3 Jul 2025 06:45:31 +0000 (23:45 -0700)]
Handle whitespace strings

15 months agoSupport path of type `SharedArrayBuffer`
Ardis Lu [Wed, 2 Jul 2025 06:02:29 +0000 (23:02 -0700)]
Support path of type `SharedArrayBuffer`

15 months agoIncrease default chunk size from 1 KiB to 64 KiB
Ardis Lu [Tue, 1 Jul 2025 04:19:16 +0000 (21:19 -0700)]
Increase default chunk size from 1 KiB to 64 KiB

Benchmarks showed improvements or no change across all tests. Notably, 100MB Read improved from ~13s to ~3s.

The magic value of 64 KiB was selected based on Node.js's default of 16 KiB in similar code [1] and manually testing some multiples over that (Node.js tends to be conservative).

[1] https://github.com/nodejs/node/blob/f69f90d97a30cf9a5f7cbe0260e487ae4d457ed5/lib/internal/fs/promises.js#L317

16 months agoRemove `scripts` and `devDependencies` from packed `package.json`
Ardis Lu [Sun, 15 Jun 2025 08:54:34 +0000 (01:54 -0700)]
Remove `scripts` and `devDependencies` from packed `package.json`

These keys are used for development purposes only, so it is wasting bandwidth to ship them with the final package.

16 months agoMove prepack script to a JS file
Ardis Lu [Sun, 15 Jun 2025 08:47:11 +0000 (01:47 -0700)]
Move prepack script to a JS file

To facilitate future more complex transformations that would be easier to manage in a code file.

16 months agoUse consistent casing
Ardis Lu [Wed, 11 Jun 2025 04:22:39 +0000 (21:22 -0700)]
Use consistent casing

16 months agoUpgrade dependencies
Ardis Lu [Wed, 11 Jun 2025 04:19:22 +0000 (21:19 -0700)]
Upgrade dependencies

16 months agoAdd code repository mirrors
Ardis Lu [Sun, 8 Jun 2025 04:44:26 +0000 (21:44 -0700)]
Add code repository mirrors

16 months agoClarify type to allow raw `ArrayBuffer`, not just `TypedArray`
Ardis Lu [Sun, 8 Jun 2025 03:42:00 +0000 (20:42 -0700)]
Clarify type to allow raw `ArrayBuffer`, not just `TypedArray`

16 months agoUpgrade dependencies
Ardis Lu [Sat, 7 Jun 2025 06:42:12 +0000 (23:42 -0700)]
Upgrade dependencies

16 months agoSimplify release notes to be auto generated
Ardis Lu [Wed, 4 Jun 2025 06:45:32 +0000 (23:45 -0700)]
Simplify release notes to be auto generated

Reasons in favor of minimal release notes: (1) Releases is a GitHub functionality, it's better not to invest too much time into vendor-specific configurations. (2) There is no binary associated with this library so Releases has reduced significance. (3) Meaningful release notes are still contained in git tag annotations, which can be carried across hosts.

One downside is losing meaningful messages in email notifications if people subscribe to follow releases on GitHub.

16 months agoCut v0.1.1 v0.1.1
Ardis Lu [Wed, 4 Jun 2025 06:24:53 +0000 (23:24 -0700)]
Cut v0.1.1

16 months agoRelease and publish on new version tags
Ardis Lu [Wed, 4 Jun 2025 06:24:27 +0000 (23:24 -0700)]
Release and publish on new version tags

16 months agoAdd keywords
Ardis Lu [Mon, 2 Jun 2025 05:09:06 +0000 (22:09 -0700)]
Add keywords

16 months agoUpdate for new scoped package name
Ardis Lu [Mon, 2 Jun 2025 05:06:07 +0000 (22:06 -0700)]
Update for new scoped package name

16 months agoPublish as scoped package v0.1.0
Ardis Lu [Mon, 2 Jun 2025 04:56:34 +0000 (21:56 -0700)]
Publish as scoped package

16 months agoAdd prepack script
Ardis Lu [Mon, 2 Jun 2025 04:42:43 +0000 (21:42 -0700)]
Add prepack script

16 months agoUpgrade dependencies
Ardis Lu [Mon, 2 Jun 2025 04:42:02 +0000 (21:42 -0700)]
Upgrade dependencies

16 months agoNormalize repository value
Ardis Lu [Fri, 30 May 2025 05:23:04 +0000 (22:23 -0700)]
Normalize repository value

Even though the shorthand is valid,  `npm publish` will show a warning every time about running `npm pkg fix` unless it is normalized.

16 months agoUse `outDir` instead of `outFile`
Ardis Lu [Fri, 30 May 2025 04:47:32 +0000 (21:47 -0700)]
Use `outDir` instead of `outFile`

`outFile` is not compatible with ES6 modules.

16 months agoTweak types
Ardis Lu [Thu, 29 May 2025 04:42:03 +0000 (21:42 -0700)]
Tweak types

16 months agoUpgrade dependencies
Ardis Lu [Thu, 29 May 2025 04:41:47 +0000 (21:41 -0700)]
Upgrade dependencies

16 months agoStrictly count the number of batches
Ardis Lu [Thu, 29 May 2025 04:00:02 +0000 (21:00 -0700)]
Strictly count the number of batches

16 months agoUpdate `maxBatchSize` behavior to match type documentation
Ardis Lu [Wed, 28 May 2025 07:26:30 +0000 (00:26 -0700)]
Update `maxBatchSize` behavior to match type documentation

**Any** value should start batching, instead of any value > 1.

16 months agoAdd overloads for raw and batch transformation variants based on options provided...
Ardis Lu [Wed, 28 May 2025 07:19:17 +0000 (00:19 -0700)]
Add overloads for raw and batch transformation variants based on options provided to the constructor

If `rawInput` is `true`, then `TransformationFunctionRaw` is required.

If `maxBatchSize` is set to any number (including `1`), then `TransformationFunctionBatch` is required.

Otherwise, `TransformationFunction` is required.

This change resolves all remaining type problems in `core.test.js`.

16 months agoRefactor `DECIMAL_SEPARATOR` to a function
Ardis Lu [Tue, 27 May 2025 05:10:07 +0000 (22:10 -0700)]
Refactor `DECIMAL_SEPARATOR` to a function

This change enables easier testing and also allows future improvements for dynamically changing the locale during runtime.

16 months agoRefine types
Ardis Lu [Tue, 27 May 2025 05:06:37 +0000 (22:06 -0700)]
Refine types

16 months agoRefactor to pass options through to private fields
Ardis Lu [Tue, 27 May 2025 05:01:57 +0000 (22:01 -0700)]
Refactor to pass options through to private fields

This change makes the code consistent with previous refactoring on the core code, and also prevents unexpected behavior from mutating the options object after instantiation.

16 months agoFix docs
Ardis Lu [Mon, 26 May 2025 05:46:56 +0000 (22:46 -0700)]
Fix docs

The retry is not necessarily immediate if `interval` is specified in options.

16 months agoRefine types
Ardis Lu [Mon, 26 May 2025 05:39:02 +0000 (22:39 -0700)]
Refine types

16 months agoExplicitly import `ReadableStream` to make TS understand `ReadableStream.from`
Ardis Lu [Sun, 25 May 2025 04:55:24 +0000 (21:55 -0700)]
Explicitly import `ReadableStream` to make TS understand `ReadableStream.from`

This change does not affect the code execution, but it makes the TS language server understand the `ReadableStream.from` static function. Without the explicit import, it is not possible using only JSDoc to merge the `ReadableStream` instance interface with the `ReadableStream` constructor because they share the same name.

16 months agoPin node types
Ardis Lu [Sun, 25 May 2025 04:51:26 +0000 (21:51 -0700)]
Pin node types

16 months agoRefactor `expandScientificNotation` to throw errors instead of using sentinel `null...
Ardis Lu [Sun, 25 May 2025 04:45:53 +0000 (21:45 -0700)]
Refactor `expandScientificNotation` to throw errors instead of using sentinel `null` value

16 months agoMigrate from CLI options to explicit `tsconfig.json`
Ardis Lu [Sun, 25 May 2025 04:24:08 +0000 (21:24 -0700)]
Migrate from CLI options to explicit `tsconfig.json`

This change makes it easier to use an explicit `lib` configuration and types, which resolves type issues resulting from subtle mismatches between implied type imports (e.g., some files importing `ReadableStream` from TS's built-in Web API types and others importing from Node.js's `streams/web`).

16 months agoFix typechecking for `parsePathLike`
Ardis Lu [Sun, 25 May 2025 02:59:56 +0000 (19:59 -0700)]
Fix typechecking for `parsePathLike`

`PathLike` only includes Node.js's `Buffer` type, need to explicitly add the web API `TypedArray` (e.g., `Uint8Array`).

17 months agoBump Node.js version for dev
Ardis Lu [Sun, 11 May 2025 05:26:52 +0000 (22:26 -0700)]
Bump Node.js version for dev

17 months agoCheck in package-lock
Ardis Lu [Sun, 11 May 2025 05:26:40 +0000 (22:26 -0700)]
Check in package-lock

17 months agoExplicitly assert that `byobRequest` and `view` are not null
Ardis Lu [Sun, 4 May 2025 02:21:40 +0000 (19:21 -0700)]
Explicitly assert that `byobRequest` and `view` are not null

17 months agoAdd TypeScript declaration file (`.d.ts`) generation
Ardis Lu [Wed, 30 Apr 2025 05:05:31 +0000 (22:05 -0700)]
Add TypeScript declaration file (`.d.ts`) generation

This is the cleanest way to make a JS library importable to a TS project. This approach is similar to Svelte's approach.

Note the dev dependency on TS is only used for `.d.ts` generation. The source code itself still does not use TS (or any dependencies other than Node.js) at all.

17 months agoAdd tests for `cancel`, `close`, and `abort`
Ardis Lu [Tue, 29 Apr 2025 04:50:32 +0000 (21:50 -0700)]
Add tests for `cancel`, `close`, and `abort`

17 months agoRefactor to avoid undefined variables
Ardis Lu [Mon, 28 Apr 2025 08:49:30 +0000 (01:49 -0700)]
Refactor to avoid undefined variables

17 months agoAdd tests for createFileStream
Ardis Lu [Mon, 28 Apr 2025 06:14:04 +0000 (23:14 -0700)]
Add tests for createFileStream

17 months agoBlock `cancel()` until `start()` is finished
Ardis Lu [Mon, 28 Apr 2025 06:07:57 +0000 (23:07 -0700)]
Block `cancel()` until `start()` is finished

If `cancel()` is called immediately after the stream is instantiated, it is possible that `start()` is not yet finished setting up the file handle before the `cancel()` logic is executed.

17 months agoRefactor to unpack `options` into private properties
Ardis Lu [Sun, 27 Apr 2025 08:38:12 +0000 (01:38 -0700)]
Refactor to unpack `options` into private properties

This change makes these properties consistent with other classes in this library. This change is also the simplest way to let the TypeScript language server understand that these properties are not null.

17 months agoRefactor to simplify for language server
Ardis Lu [Sun, 27 Apr 2025 08:30:01 +0000 (01:30 -0700)]
Refactor to simplify for language server

The TypeScript language server is not yet capable of understanding that the nullish coalescing assignment will make the property non-null, so it will show a type error. Another workaround would be to assert the property is non-null using a JSDoc equivalent to TypeScript's `!` but that is also not yet supported by JSDoc.

This page took 0.097887 seconds and 4 git commands to generate.