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

    Interface TrackLocationOption<TrackLocation>

    Options for enabling location tracking in lexer output.

    interface TrackLocationOption<TrackLocation extends boolean = false> {
        trackLocation?: TrackLocation;
    }

    Type Parameters

    • TrackLocation extends boolean = false

    Hierarchy (View Summary)

    Index

    Properties

    Properties

    trackLocation?: TrackLocation

    Enable location tracking for tokens.

    When enabled, tokens include location with start, end Position objects and rowNumber. This is useful for error reporting but adds overhead.

    Performance impact:

    • false (default): No location tracking, maximum performance
    • true: Full location tracking with Position objects

    When to enable:

    • Custom error handling that needs line/column information
    • Building source maps or editors
    • Debugging CSV parsing issues

    Note: High-level APIs (parseString, etc.) always use trackLocation: false for performance. This option is only available in low-level Lexer APIs.

    false
    
    // No location tracking (default, fastest)
    const lexer = new FlexibleStringCSVLexer();
    for (const token of lexer.lex(csv)) {
    console.log(token); // { type: Field, value: 'foo' }
    }

    // With location tracking
    const lexer = new FlexibleStringCSVLexer({ trackLocation: true });
    for (const token of lexer.lex(csv)) {
    console.log(token);
    // { type: Field, value: 'foo', location: { start: {...}, end: {...}, rowNumber: 1 } }
    }