web-csv-toolbox - v0.14.0
    Preparing search index...

    Platform-Specific Usage Guide

    Guide for using web-csv-toolbox across different JavaScript runtime environments.


    Common CSV parsing scenarios in web browsers:

    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), use parseBlob() with a manual source option: parseBlob(blob, { source: 'filename.csv' }).


    • Use streaming for large files - Prefer parseBinaryStream() over loading entire files
    • Process incrementally - Use for await...of to handle records one at a time
    • Avoid .toArray() for large datasets - Loads entire result into memory
    • Always use try-catch - Wrap parsing operations in error handlers
    • Validate inputs - Check file types and sizes before parsing
    • Provide user feedback - Display clear error messages
    • Use source tracking - Specify source option or use parseFile() for automatic filename tracking
    • Check error types - Handle ParseError, RangeError, and DOMException appropriately

    Example:

    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');
    }
    }
    • Enable compression - Use gzip for network transfers
    • Use AbortSignal - Implement timeout protection for untrusted sources
    • Batch processing - Process records in batches for database operations

    For complete, working examples on different platforms: