Skip to content

Commit 9a53c3c

Browse files
Version Packages (#615)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent eabb995 commit 9a53c3c

File tree

8 files changed

+187
-190
lines changed

8 files changed

+187
-190
lines changed

.changeset/column-count-strategy-rename.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

.changeset/const-type-parameters.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

.changeset/lexer-api-changes.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

.changeset/performance-improvements.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

.changeset/stream-factory-functions.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

.changeset/supply-chain-defense.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,191 @@
11
# web-csv-toolbox
22

3+
## 0.15.0
4+
5+
### Minor Changes
6+
7+
- [#614](https://github.com/kamiazya/web-csv-toolbox/pull/614) [`25d49ee`](https://github.com/kamiazya/web-csv-toolbox/commit/25d49ee16f356ba87a552ff75324e1d7d88e1639) Thanks [@kamiazya](https://github.com/kamiazya)! - **BREAKING CHANGE**: Restrict `columnCountStrategy` options for object output to `fill`/`strict` only.
8+
9+
Object format now rejects `keep` and `truncate` strategies at runtime, as these strategies are incompatible with object output semantics. Users relying on `keep` or `truncate` with object format must either:
10+
11+
- Switch to `outputFormat: 'array'` to use these strategies, or
12+
- Use `fill` (default) or `strict` for object output
13+
14+
This change improves API clarity by aligning strategy availability with format capabilities and documenting the purpose-driven strategy matrix (including sparse/header requirements).
15+
16+
- [#616](https://github.com/kamiazya/web-csv-toolbox/pull/616) [`8adf5d9`](https://github.com/kamiazya/web-csv-toolbox/commit/8adf5d9e0300013efcc90493682f0103fb0ddb81) Thanks [@kamiazya](https://github.com/kamiazya)! - Add TypeScript 5.0 const type parameters to eliminate `as const` requirements
17+
18+
**New Features:**
19+
20+
- Add `CSVOutputFormat` type alias for `"object" | "array"` union type
21+
- Implement const type parameters in factory functions for automatic literal type inference
22+
- Add function overloads to factory functions for precise return type narrowing
23+
- Users no longer need to write `as const` when specifying headers, delimiters, or other options
24+
25+
**Improvements:**
26+
27+
- Replace `import("@/...").XXX` patterns with standard import statements at file top
28+
- Update factory function type signatures to use const type parameters:
29+
- `createStringCSVParser` - automatically infers header, delimiter, quotation, and output format types
30+
- `createBinaryCSVParser` - automatically infers header, delimiter, quotation, charset, and output format types
31+
- `createCSVRecordAssembler` - automatically infers header and output format types
32+
- Update type definitions to support const type parameters:
33+
- `CSVRecordAssemblerCommonOptions` - add `OutputFormat` and `Strategy` type parameters
34+
- `CSVProcessingOptions` - add `OutputFormat` type parameter
35+
- `BinaryOptions` - add `Charset` type parameter
36+
- Update JSDoc examples in factory functions to remove unnecessary `as const` annotations
37+
- Update README.md examples to demonstrate simplified usage without `as const`
38+
39+
**Before:**
40+
41+
```typescript
42+
const parser = createStringCSVParser({
43+
header: ["name", "age"] as const, // Required as const
44+
outputFormat: "object",
45+
});
46+
```
47+
48+
**After:**
49+
50+
```typescript
51+
const parser = createStringCSVParser({
52+
header: ["name", "age"], // Automatically infers literal types
53+
outputFormat: "object", // Return type properly narrowed
54+
});
55+
```
56+
57+
**Technical Details:**
58+
59+
- Leverages TypeScript 5.0's const type parameters feature
60+
- Uses function overloads to narrow return types based on `outputFormat` value:
61+
- `outputFormat: "array"` → returns array parser
62+
- `outputFormat: "object"` → returns object parser
63+
- omitted → defaults to object parser
64+
- dynamic value → returns union type
65+
- All changes are 100% backward compatible
66+
- Existing code using `as const` continues to work unchanged
67+
68+
- [#614](https://github.com/kamiazya/web-csv-toolbox/pull/614) [`25d49ee`](https://github.com/kamiazya/web-csv-toolbox/commit/25d49ee16f356ba87a552ff75324e1d7d88e1639) Thanks [@kamiazya](https://github.com/kamiazya)! - ## Lexer API Changes
69+
70+
This release includes low-level Lexer API changes for performance optimization.
71+
72+
### Breaking Changes (Low-level API only)
73+
74+
These changes only affect users of the low-level Lexer API. **High-level APIs (`parseString`, `parseBinary`, etc.) are unchanged.**
75+
76+
1. **Token type constants**: Changed from `Symbol` to numeric constants
77+
2. **Location tracking**: Now disabled by default. Add `trackLocation: true` to Lexer options if you need token location information. Note: Error messages still include position information even when `trackLocation: false` (computed lazily only when errors occur).
78+
3. **Struct of token objects**: Changed to improve performance. Token properties changed and reduce tokens by combining delimiter and newline information into a field.
79+
80+
### Who is affected?
81+
82+
**Most users are NOT affected.** Only users who directly use `FlexibleStringCSVLexer` and rely on `token.location` or `Symbol`-based token type comparison need to update their code.
83+
84+
- [#613](https://github.com/kamiazya/web-csv-toolbox/pull/613) [`2a7b22e`](https://github.com/kamiazya/web-csv-toolbox/commit/2a7b22edf20f9c4859a12b2609cc3075afcc316f) Thanks [@kamiazya](https://github.com/kamiazya)! - Add factory functions for stream-based CSV parsing APIs
85+
86+
**New Features:**
87+
88+
- Add `createStringCSVParserStream()` factory function for Mid-level string stream parsing
89+
- Add `createBinaryCSVParserStream()` factory function for Mid-level binary stream parsing
90+
- Add `createStringCSVLexerTransformer()` factory function for creating StringCSVLexerTransformer instances
91+
- Add `createCSVRecordAssemblerTransformer()` factory function for creating CSVRecordAssemblerTransformer instances
92+
- Add `StringCSVLexerOptions` type for lexer factory function options
93+
- Add `StringCSVLexerTransformerStreamOptions` type for stream behavior options
94+
- Add `CSVRecordAssemblerFactoryOptions` type for assembler factory function options
95+
- Add `StringCSVParserFactoryOptions` type for string parser factory function options
96+
- Add `BinaryCSVParserFactoryOptions` type for binary parser factory function options
97+
- Update model factory functions (`createStringCSVLexer`, `createCSVRecordAssembler`, `createStringCSVParser`, `createBinaryCSVParser`) to accept engine options for future optimization support
98+
- Update documentation with API level classification (High-level, Mid-level, Low-level)
99+
100+
**Breaking Changes:**
101+
102+
- Rename `CSVLexerTransformer` class to `StringCSVLexerTransformer` to clarify input type (string)
103+
- Rename `createCSVLexerTransformer()` to `createStringCSVLexerTransformer()` for consistency
104+
- Rename `CSVLexerTransformerStreamOptions` type to `StringCSVLexerTransformerStreamOptions` for naming consistency
105+
- Remove unused `CSVLexerTransformerOptions` type
106+
107+
**Migration:**
108+
109+
```typescript
110+
// Before
111+
import {
112+
CSVLexerTransformer,
113+
createCSVLexerTransformer,
114+
type CSVLexerTransformerStreamOptions,
115+
} from "web-csv-toolbox";
116+
new CSVLexerTransformer(lexer);
117+
createCSVLexerTransformer({ delimiter: "," });
118+
119+
// After
120+
import {
121+
StringCSVLexerTransformer,
122+
createStringCSVLexerTransformer,
123+
type StringCSVLexerTransformerStreamOptions,
124+
} from "web-csv-toolbox";
125+
new StringCSVLexerTransformer(lexer);
126+
createStringCSVLexerTransformer({ delimiter: "," });
127+
```
128+
129+
These factory functions simplify the API by handling internal parser/lexer creation, reducing the impact of future internal changes on user code. This addresses the issue where CSVLexerTransformer constructor signature changed in v0.14.0 (#612).
130+
131+
### Patch Changes
132+
133+
- [#614](https://github.com/kamiazya/web-csv-toolbox/pull/614) [`25d49ee`](https://github.com/kamiazya/web-csv-toolbox/commit/25d49ee16f356ba87a552ff75324e1d7d88e1639) Thanks [@kamiazya](https://github.com/kamiazya)! - ## JavaScript Parser Performance Improvements
134+
135+
This release includes significant internal optimizations that improve JavaScript-based CSV parsing performance.
136+
137+
### Before / After Comparison
138+
139+
| Metric | Before (v0.14) | After | Improvement |
140+
| ----------------------- | -------------- | --------- | -------------- |
141+
| 1,000 rows parsing | 3.57 ms | 1.42 ms | **60% faster** |
142+
| 5,000 rows parsing | 19.47 ms | 7.03 ms | **64% faster** |
143+
| Throughput (1,000 rows) | 24.3 MB/s | 61.2 MB/s | **2.51x** |
144+
| Throughput (5,000 rows) | 24.5 MB/s | 67.9 MB/s | **2.77x** |
145+
146+
### Optimization Summary
147+
148+
| Optimization | Target | Improvement |
149+
| -------------------------------------- | --------- | ---------------------------------- |
150+
| Array copy method improvement | Assembler | -8.7% |
151+
| Quoted field parsing optimization | Lexer | Overhead eliminated |
152+
| Object assembler loop optimization | Assembler | -5.4% |
153+
| Regex removal for unquoted fields | Lexer | -14.8% |
154+
| String comparison optimization | Lexer | ~10% |
155+
| Object creation optimization | Lexer | ~20% |
156+
| Non-destructive buffer reading | GC | -46% |
157+
| Token type numeric conversion | Lexer/GC | -7% / -13% |
158+
| Location tracking made optional | Lexer | -19% to -31% |
159+
| Object.create(null) for records | Assembler | -31% |
160+
| Empty-row template cache | Assembler | ~4% faster on sparse CSV |
161+
| Row buffer reuse (no per-record slice) | Assembler | ~6% faster array format |
162+
| Header-length builder preallocation | Assembler | Capacity stays steady on wide CSV |
163+
| Object assembler row buffer pooling | Assembler | Lower GC spikes on object output |
164+
| Lexer segment-buffer pooling | Lexer | Smoother GC for quoted-heavy input |
165+
166+
### Final Performance Results (Pure JavaScript)
167+
168+
| Format | Throughput |
169+
| -------------------------- | ------------- |
170+
| Object format (1,000 rows) | **61.2 MB/s** |
171+
| Array format (1,000 rows) | **87.6 MB/s** |
172+
| Object format (5,000 rows) | **67.9 MB/s** |
173+
| Array format (5,000 rows) | **86.4 MB/s** |
174+
175+
Array format is approximately 43% faster (1.43× throughput) than Object format for the same data.
176+
177+
- [#617](https://github.com/kamiazya/web-csv-toolbox/pull/617) [`eabb995`](https://github.com/kamiazya/web-csv-toolbox/commit/eabb9955a23ffe1299b860b6637680698b0819b8) Thanks [@kamiazya](https://github.com/kamiazya)! - ## Supply Chain Attack Defense
178+
179+
Added multi-layered protection against npm supply chain attacks (such as Shai-Hulud 2.0).
180+
181+
### Defense Layers
182+
183+
1. **New Package Release Delay**: Blocks packages published within 48 hours via `minimumReleaseAge` setting
184+
2. **Install Script Prevention**: Disables preinstall/postinstall scripts via `ignore-scripts=true`
185+
3. **Continuous Vulnerability Scanning**: Integrates OSV-Scanner into CI/CD pipeline
186+
187+
These changes only affect the development environment and CI/CD configuration. No changes to library code.
188+
3189
## 0.14.0
4190

5191
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-csv-toolbox",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"description": "A CSV Toolbox utilizing Web Standard APIs.",
55
"type": "module",
66
"module": "dist/main.web.js",

0 commit comments

Comments
 (0)