Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Jan 13, 2026

Summary

  • Adds StreamParser class to JavaScript and Rust implementations for efficient streaming parsing of large Links Notation messages
  • Adds ParseError/StreamParseError types with detailed location information (line, column, offset)
  • Updates documentation with streaming parser examples and API reference
  • Bumps version from 0.13.0 to 0.14.0

Features

JavaScript StreamParser

import { StreamParser, ParseError } from 'links-notation';

const parser = new StreamParser();

parser.on('link', (link) => {
  // Process each link as it's parsed
  console.log(link);
});

parser.on('error', (error) => {
  // Handle parse errors with location info
  console.error(`Error at line ${error.line}, col ${error.column}: ${error.message}`);
});

// Feed data incrementally
parser.write(chunk1);
parser.write(chunk2);
const links = parser.end();

Rust StreamParser

use links_notation::stream_parser::StreamParser;

let mut parser = StreamParser::new();

parser.on_link(|link| {
    println!("{:?}", link);
});

parser.write(chunk1)?;
parser.write(chunk2)?;
let links = parser.finish()?;

Benefits

  1. Memory efficiency: Process large messages without loading everything into memory
  2. Low latency: Start processing before the full message is received
  3. Detailed error reporting: Errors include line and column information for debugging
  4. Event-based API: Receive links as they are parsed

Test plan

  • Added 35 unit tests for JavaScript StreamParser
  • Added 14 unit tests for Rust StreamParser (plus 5 doc tests)
  • All existing tests continue to pass (223 JS tests, 200+ Rust tests)
  • Verified streaming parser produces same results as regular Parser
  • Tested incremental input, buffering, error handling, and reset functionality

Fixes #197


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #197
@konard konard self-assigned this Jan 13, 2026
This commit adds a StreamParser class to both JavaScript and Rust implementations
for efficient processing of large Links Notation messages.

Features:
- Event-based API to receive links as they are parsed
- Memory efficient: no need to load entire message into memory
- Detailed error reporting with line/column information
- Incremental input via write() method
- Reset functionality for parser reuse

JavaScript API:
- StreamParser class with on('link'), on('error'), on('end') events
- ParseError class with line, column, offset properties
- write(chunk), end(), reset(), getLinks() methods

Rust API:
- StreamParser struct with on_link() and on_error() callbacks
- StreamParseError with location information
- write(), finish(), reset(), get_links() methods

Closes #197

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add streaming parser for large message handling Add streaming parser API for large message handling Jan 13, 2026
konard and others added 2 commits January 13, 2026 13:14
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 13, 2026 12:17
@konard
Copy link
Member Author

konard commented Jan 13, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.281981 USD
  • Calculated by Anthropic: $5.416125 USD
  • Difference: $-1.865856 (-25.62%)
    📎 Log file uploaded as Gist (1326KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add streaming parser for large message handling

2 participants