Guide for using web-csv-toolbox across different JavaScript runtime environments.
Common CSV parsing scenarios in web browsers:
<input type="file">Working with CSV in Node.js applications:
CSV parsing in Deno runtime:
| Environment | Input Type | API | Guide |
|---|---|---|---|
| Browser | File |
parseFile() |
File Input |
File (dropped) |
parseFile() |
Drag & Drop | |
FormData |
parseFile() |
FormData | |
Response |
parseResponse() |
Fetch | |
| Node.js | Buffer |
parseBinary() |
Buffer |
fs.ReadStream |
parseBinaryStream() |
FS Stream | |
Response |
parseResponse() |
HTTP | |
| stdin | parseBinaryStream() |
stdin/stdout | |
stream.Readable |
parseBinaryStream() |
Stream Conversion | |
| Deno | Uint8Array |
parseBinary() |
readFile |
ReadableStream |
parseBinaryStream() |
open | |
Response |
parseResponse() |
fetch |
Note:
parseFile()automatically includes the filename in error messages. For environments where the File constructor is unavailable (e.g., Cloudflare Workers), useparseBlob()with a manualsourceoption:parseBlob(blob, { source: 'filename.csv' }).
parseBinaryStream() over loading entire filesfor await...of to handle records one at a time.toArray() for large datasets - Loads entire result into memorysource option or use parseFile() for automatic filename trackingParseError, RangeError, and DOMException appropriatelyExample:
import { parseFile, ParseError } from 'web-csv-toolbox';
try {
for await (const record of parseFile(file)) {
await processRecord(record);
}
} catch (error) {
if (error instanceof ParseError) {
// CSV format error - includes filename automatically
console.error(`Parse error in "${error.source}":`, error.message);
} else if (error instanceof RangeError) {
// Security limit exceeded
console.error('File exceeds security limits');
} else if (error instanceof DOMException && error.name === 'AbortError') {
// Operation cancelled
console.log('Parsing cancelled');
}
}
For complete, working examples on different platforms: