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.
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.
Ardis Lu [Fri, 4 Apr 2025 07:12:25 +0000 (00:12 -0700)]
Test UTF-16 BE decoding
`utf-16be` is not supported by Node.js's decoder in the `fs` module, but it is supported by the web standard Encoding API. So this is a good test to demonstrate the difference between the two.
Ardis Lu [Fri, 4 Apr 2025 06:51:45 +0000 (23:51 -0700)]
Remove dependency on Node.js `createReadStream`
This change decouples the file reading from the character decoding, which enables use of the web standard Encoding API (`TextDecoderStream`) instead of Node.js's internal decoder. The web standard allows a broader set of encodings.
Ardis Lu [Tue, 11 Feb 2025 06:41:02 +0000 (22:41 -0800)]
Assert non-nullable type instead of using nullish coalesce
There will be undefined `decimal` only if the input to `formatToParts` does not contain a decimal. But there will always be a decimal because the input is hardcoded.
The TS language server is not yet intelligent enough to assert it is non-nullable from the hardcoded input, so we need to pass the type hint.
Using nullish coalesce results in an uncovered branch which is impossible to test, so it should be removed.
Ardis Lu [Mon, 10 Feb 2025 04:21:02 +0000 (20:21 -0800)]
Delete unnecessary token
Originally intended to match the remaining characters of the rest of the test name, but this is not needed since we only need to match the "large:" prefix.
Ardis Lu [Sat, 8 Feb 2025 09:47:24 +0000 (01:47 -0800)]
Fix temp files not being deleted
The test runner will run code inside a test suite block even if the tests inside are skipped, which means the temp file was created but the cleanup `after()` call is skipped. Putting the creation within `before()` makes the temp file creation skipped it the tests are skipped.
Ardis Lu [Fri, 24 Jan 2025 03:47:14 +0000 (19:47 -0800)]
Allow Array<any> and TransformationFunction as inputs to handle headers
This change simplifies the common tasks of (1) renaming headers (just pass the new header array) and (2) appending headers (pass a one-line TransformationFunction). Setting the option to a boolean is the same behavior as includeHeaders.
Ardis Lu [Wed, 22 Jan 2025 05:59:15 +0000 (21:59 -0800)]
Renumber and categorize examples
Headers make the examples easier to skim. Using minor numberings is also useful to later add more examples without having to renumber existing groupings each time.
Ardis Lu [Sat, 18 Jan 2025 07:52:29 +0000 (23:52 -0800)]
Add maxBatchSize option
Although this functionality could be implemented by end-users by returning null in the transformation function until a batch is accumulated, baking it into the transform stream simplifies this common use case.