jtcsv 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -133,6 +133,7 @@ Converts an array of objects to CSV string.
133
133
  Converts CSV string to array of objects.
134
134
 
135
135
  **Options:**
136
+ Fast path parsing is the default pipeline; use `fastPathMode` to control row shape.
136
137
  - `delimiter` (string): Delimiter (auto-detected if not specified)
137
138
  - `autoDetect` (boolean, default: true): Auto-detect delimiter
138
139
  - `hasHeaders` (boolean, default: true): CSV has header row
@@ -140,6 +141,22 @@ Converts CSV string to array of objects.
140
141
  - `parseBooleans` (boolean, default: false): Parse boolean values
141
142
  - `trim` (boolean, default: true): Trim whitespace
142
143
  - `maxRows` (number): Maximum rows to process
144
+ - `useFastPath` (boolean, default: true): Enable fast-path parser (set `false` to force quote-aware path)
145
+ - `fastPathMode` (string, default: 'objects'): `'objects'` for object rows, `'compact'` for arrays (lower memory), `'stream'` to return an async iterator
146
+
147
+ #### `csvToJsonIterator(csv, options)`
148
+ Convert CSV to JSON rows as an async iterator for large inputs.
149
+ You can also call `csvToJson(csv, { fastPathMode: 'stream' })` to get the same async iterator.
150
+
151
+ **Example:**
152
+ ```javascript
153
+ const { csvToJsonIterator } = require('jtcsv');
154
+
155
+ const csv = 'id,name\n1,Jane\n2,John';
156
+ for await (const row of csvToJsonIterator(csv, { fastPathMode: 'compact' })) {
157
+ console.log(row);
158
+ }
159
+ ```
143
160
 
144
161
  ### Browser-Specific Functions
145
162
 
@@ -264,19 +281,34 @@ const unsafeCsv = jsonToCsv(dangerousData, { preventCsvInjection: false });
264
281
 
265
282
  ## 📊 Performance
266
283
 
267
- ### Benchmark Results
284
+ ### Benchmark Results (Node.js 22, 10K rows/records)
285
+
286
+ **CSV → JSON (10K rows)**
287
+
288
+ | Library | Time | Memory | Rank |
289
+ |---------|------|--------|------|
290
+ | **JTCSV (FastPath Compact)** | 16.79 ms | 4.47 MB | 🥇 1st |
291
+ | **JTCSV (FastPath Stream)** | 18.27 ms | 6.03 MB | 🥈 2nd |
292
+ | **JTCSV** | 19.76 ms | 8.96 MB | 🥉 3rd |
293
+ | PapaParse | 21.57 ms | 6.97 MB | 4th |
294
+ | csv-parser | 30.52 ms | 6.53 MB | 5th |
268
295
 
269
- | File Size | Rows | Without Workers | With Workers | Improvement |
270
- |-----------|------|-----------------|--------------|-------------|
271
- | 1 MB | 10K | 120 ms | 80 ms | 33% faster |
272
- | 10 MB | 100K | 1.2 sec | 0.8 sec | 33% faster |
273
- | 100 MB | 1M | 12 sec | 7 sec | 42% faster |
274
- | 500 MB | 5M | 65 sec | 35 sec | 46% faster |
296
+ **JSON CSV (10K records)**
275
297
 
276
- ### Memory Usage
277
- - **Without streaming**: Loads entire file into memory
278
- - **With streaming**: Processes in chunks (default 10K rows)
279
- - **With Web Workers**: Distributes memory across workers
298
+ | Library | Time | Memory | Rank |
299
+ |---------|------|--------|------|
300
+ | **JTCSV** | 11.21 ms | 4.77 MB | 🥇 1st |
301
+ | json2csv | 12.27 ms | 12.11 MB | 🥈 2nd |
302
+
303
+ ### Scaling (JTCSV only)
304
+
305
+ | Rows/Records | CSV→JSON Time (FastPath Compact) | JSON→CSV Time (JTCSV) | CSV→JSON Memory | JSON→CSV Memory |
306
+ |--------------|----------------------------------|-----------------------|-----------------|-----------------|
307
+ | 1,000 | 2.06 ms | 1.04 ms | 2.15 MB | 0.52 MB |
308
+ | 10,000 | 14.68 ms | 8.23 ms | 2.11 MB | 4.14 MB |
309
+ | 100,000 | 164.18 ms | 90.93 ms | 44.93 MB | 34.79 MB |
310
+
311
+ See `BENCHMARK-RESULTS.md` and `docs/PERFORMANCE.md` for environment details and methodology.
280
312
 
281
313
  ## 🛠️ Development
282
314
 
@@ -345,7 +377,3 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
345
377
  ---
346
378
 
347
379
  **Happy coding!** If you find this library useful, please consider giving it a star on GitHub ⭐
348
-
349
-
350
-
351
-