web-csv-toolbox 0.13.1-next-f8d7ffbf9fd4fd2fe596d7250cc86bc361c376df → 0.14.0-next-fe8f8c27b5fcf2744b32ad7dca0a70ed7f47c915

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.
Files changed (48) hide show
  1. package/README.md +74 -9
  2. package/dist/_virtual/web_csv_toolbox_wasm_bg.wasm.js +1 -1
  3. package/dist/common/types.d.ts +1 -1
  4. package/dist/execution/worker/helpers/createWorker.node.js +1 -1
  5. package/dist/execution/worker/helpers/createWorker.node.js.map +1 -1
  6. package/dist/execution/worker/helpers/createWorker.web.js +1 -1
  7. package/dist/execution/worker/helpers/createWorker.web.js.map +1 -1
  8. package/dist/getOptionsFromBlob.d.ts +10 -0
  9. package/dist/getOptionsFromBlob.js +18 -0
  10. package/dist/getOptionsFromBlob.js.map +1 -0
  11. package/dist/getOptionsFromRequest.d.ts +11 -0
  12. package/dist/getOptionsFromRequest.js +41 -0
  13. package/dist/getOptionsFromRequest.js.map +1 -0
  14. package/dist/parse.d.ts +4 -2
  15. package/dist/parse.js +11 -29
  16. package/dist/parse.js.map +1 -1
  17. package/dist/parseBlob.d.ts +102 -0
  18. package/dist/parseBlob.js +31 -0
  19. package/dist/parseBlob.js.map +1 -0
  20. package/dist/parseBlobToStream.d.ts +11 -0
  21. package/dist/parseBlobToStream.js +10 -0
  22. package/dist/parseBlobToStream.js.map +1 -0
  23. package/dist/parseFile.d.ts +93 -0
  24. package/dist/parseFile.js +20 -0
  25. package/dist/parseFile.js.map +1 -0
  26. package/dist/parseRequest.d.ts +120 -0
  27. package/dist/parseRequest.js +37 -0
  28. package/dist/parseRequest.js.map +1 -0
  29. package/dist/parseRequestToStream.d.ts +11 -0
  30. package/dist/parseRequestToStream.js +16 -0
  31. package/dist/parseRequestToStream.js.map +1 -0
  32. package/dist/parseResponse.js +1 -6
  33. package/dist/parseResponse.js.map +1 -1
  34. package/dist/web-csv-toolbox.d.ts +3 -0
  35. package/dist/web-csv-toolbox.js +3 -0
  36. package/dist/web-csv-toolbox.js.map +1 -1
  37. package/dist/web_csv_toolbox_wasm_bg.wasm +0 -0
  38. package/dist/worker.node.d.ts +1 -1
  39. package/dist/{execution/worker/helpers/worker.node.js → worker.node.js} +1 -1
  40. package/dist/worker.node.js.map +1 -0
  41. package/dist/worker.web.d.ts +1 -1
  42. package/dist/{execution/worker/helpers/worker.web.js → worker.web.js} +1 -1
  43. package/dist/worker.web.js.map +1 -0
  44. package/package.json +15 -1
  45. package/dist/execution/worker/helpers/worker.node.d.ts +0 -1
  46. package/dist/execution/worker/helpers/worker.node.js.map +0 -1
  47. package/dist/execution/worker/helpers/worker.web.d.ts +0 -1
  48. package/dist/execution/worker/helpers/worker.web.js.map +0 -1
package/README.md CHANGED
@@ -56,13 +56,13 @@ A CSV Toolbox utilizing Web Standard APIs.
56
56
  - ⏳ Use [`AbortSignal.timeout`](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) to automatically cancel operations that exceed a specified time limit.
57
57
  - 🛡️ **Memory Safety Protection**: Built-in limits prevent memory exhaustion attacks.
58
58
  - 🔒 Configurable maximum buffer size (default: 10M characters) to prevent DoS attacks via unbounded input.
59
- - 🚨 Throws `RangeError` when buffer exceeds the limit.
59
+ - 🚨 Throws `RangeError` when buffer exceeds the limit.
60
60
  - 📊 Configurable maximum field count (default: 100,000 fields/record) to prevent excessive column attacks.
61
- - ⚠️ Throws `RangeError` when field count exceeds the limit.
61
+ - ⚠️ Throws `RangeError` when field count exceeds the limit.
62
62
  - 💾 Configurable maximum binary size (default: 100MB bytes) for ArrayBuffer/Uint8Array inputs.
63
- - 🛑 Throws `RangeError` when binary size exceeds the limit.
63
+ - 🛑 Throws `RangeError` when binary size exceeds the limit.
64
64
  - 🎨 **Flexible Source Support**
65
- - 🧩 Parse CSVs directly from `string`s, `ReadableStream`s, or `Response` objects.
65
+ - 🧩 Parse CSVs directly from `string`s, `ReadableStream`s, `Response` objects, `Blob`/`File` objects, or `Request` objects.
66
66
  - ⚙️ **Advanced Parsing Options**: Customize your experience with various delimiters and quotation marks.
67
67
  - 🔄 Defaults to `,` and `"` respectively.
68
68
  - 💾 **Specialized Binary CSV Parsing**: Leverage Stream-based processing for versatility and strength.
@@ -115,6 +115,8 @@ import { parse } from "npm:web-csv-toolbox";
115
115
 
116
116
  ## Usage 📘
117
117
 
118
+ > **Note for Bundler Users**: When using Worker-based execution strategies (e.g., `EnginePresets.worker()`, `EnginePresets.workerWasm()`) with bundlers like Vite or Webpack, you must explicitly specify the `workerURL` option. See the [Bundler Integration Guide](./docs/how-to-guides/use-with-bundlers.md) for configuration details.
119
+
118
120
  ### Parsing CSV files from strings
119
121
 
120
122
  ```js
@@ -171,6 +173,47 @@ for await (const record of parse(response)) {
171
173
  // { name: 'Bob', age: '69' }
172
174
  ```
173
175
 
176
+ ### Parsing CSV files from `Blob` or `File` objects
177
+
178
+ ```js
179
+ import { parse } from 'web-csv-toolbox';
180
+
181
+ // From file input
182
+ const fileInput = document.querySelector('input[type="file"]');
183
+ fileInput.addEventListener('change', async (e) => {
184
+ const file = e.target.files[0];
185
+
186
+ for await (const record of parse(file)) {
187
+ console.log(record);
188
+ }
189
+ // Prints:
190
+ // { name: 'Alice', age: '42' }
191
+ // { name: 'Bob', age: '69' }
192
+ });
193
+ ```
194
+
195
+ ### Parsing CSV files from `Request` objects (Server-side)
196
+
197
+ ```js
198
+ import { parse } from 'web-csv-toolbox';
199
+
200
+ // Cloudflare Workers / Service Workers
201
+ export default {
202
+ async fetch(request) {
203
+ if (request.method === 'POST') {
204
+ for await (const record of parse(request)) {
205
+ console.log(record);
206
+ }
207
+ // Prints:
208
+ // { name: 'Alice', age: '42' }
209
+ // { name: 'Bob', age: '69' }
210
+
211
+ return new Response('OK', { status: 200 });
212
+ }
213
+ }
214
+ };
215
+ ```
216
+
174
217
  ### Parsing CSV files with different delimiters and quotation characters
175
218
 
176
219
  ```js
@@ -314,6 +357,19 @@ try {
314
357
 
315
358
  - Verify that JavaScript is executable on the Deno. [![Deno CI](https://github.com/kamiazya/web-csv-toolbox/actions/workflows/deno.yaml/badge.svg)](https://github.com/kamiazya/web-csv-toolbox/actions/workflows/deno.yaml)
316
359
 
360
+ ### Platform-Specific Usage Guide 📚
361
+
362
+ For detailed examples and best practices for your specific runtime environment, see:
363
+
364
+ **[Platform-Specific Usage Guide](./docs/how-to-guides/platform-usage/)**
365
+
366
+ This guide covers:
367
+ - 🌐 **Browser**: File input, drag-and-drop, Clipboard API, FormData, Fetch API
368
+ - 🟢 **Node.js**: Buffer, fs.ReadStream, HTTP requests, stdin/stdout
369
+ - 🦕 **Deno**: Deno.readFile, Deno.open, fetch API
370
+ - ⚡ **Edge**: Cloudflare Workers, Deno Deploy, Vercel Edge Functions
371
+ - 🐰 **Bun**: File API, HTTP server
372
+
317
373
  ## APIs 🧑‍💻
318
374
 
319
375
  ### High-level APIs 🚀
@@ -326,11 +382,14 @@ providing an intuitive and straightforward experience for users.
326
382
  - **`function parse.toArray(input[, options]): Promise<CSVRecord[]>`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parse.toArray.html)
327
383
  - Parses CSV input into an array of records, ideal for smaller data sets.
328
384
 
329
- The `input` paramater can be a `string`, a [ReadableStream](https://developer.mozilla.org/docs/Web/API/ReadableStream)
330
- of `string`s or [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)s,
331
- or a [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) object,
332
- or a [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) object,
333
- or a [Response](https://developer.mozilla.org/docs/Web/API/Response) object.
385
+ The `input` paramater can be:
386
+ - a `string`
387
+ - a [ReadableStream](https://developer.mozilla.org/docs/Web/API/ReadableStream) of `string`s or [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)s
388
+ - a [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) object
389
+ - an [ArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) object
390
+ - a [Response](https://developer.mozilla.org/docs/Web/API/Response) object
391
+ - a [Blob](https://developer.mozilla.org/docs/Web/API/Blob) or [File](https://developer.mozilla.org/docs/Web/API/File) object
392
+ - a [Request](https://developer.mozilla.org/docs/Web/API/Request) object (server-side)
334
393
 
335
394
  ### Middle-level APIs 🧱
336
395
 
@@ -343,6 +402,12 @@ catering to users who need more detailed and fine-tuned functionality.
343
402
  - Parse CSV Binary of ArrayBuffer or Uint8Array.
344
403
  - **`function parseResponse(response[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseResponse-1.html)
345
404
  - Customized parsing directly from `Response` objects.
405
+ - **`function parseRequest(request[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseRequest-1.html)
406
+ - Server-side parsing from `Request` objects (Cloudflare Workers, Service Workers, etc.).
407
+ - **`function parseBlob(blob[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseBlob-1.html)
408
+ - Parse CSV data from `Blob` or `File` objects.
409
+ - **`function parseFile(file[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseFile-1.html)
410
+ - Alias for `parseBlob`, semantically clearer for `File` objects.
346
411
  - **`function parseStream(stream[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseStream-1.html)
347
412
  - Stream-based parsing for larger or continuous data.
348
413
  - **`function parseStringStream(stream[, options])`**: [📑](https://kamiazya.github.io/web-csv-toolbox/functions/parseStringStream-1.html)