Adds an opt-in streaming option that processes files through Node
streams with bounded memory usage, addressing #128:
- Files larger than V8's maximum string size (~500MB), which previously
failed outright with ERR_STRING_TOO_LONG, can now be processed;
verified with a 609MB file under a 64MB heap cap
- Matches are found across chunk boundaries via a sliding window:
plain strings are always matched exactly, regex matches are exact up
to a configurable maxMatchLength window (default 1024 chars)
- A context window of already emitted text keeps multiline anchors and
lookbehind assertions correct at chunk seams
- Full feature parity with buffered mode: from/to arrays, callbacks,
$-pattern expansion, named groups, countMatches, dry runs and
getTargetFile all behave identically (verified differentially against
the buffered implementation at every chunk size)
- Changed files are written atomically via a temp file and rename,
preserving file mode and never leaving a target half written
- Available in the CLI via --streaming and --maxMatchLength
- Streaming is async-only and cannot be combined with processors or a
custom fs; these combinations throw clear errors
Closes #128
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>