finds.dev← search

// the find

mcollina/split2

★ 296 · JavaScript · ISC · updated Jul 2026

Split Streams3 style

split2 is a tiny Node.js Transform stream that splits a stream into lines (or NDJSON objects via a mapper function). It's for anyone doing line-oriented stream processing in Node — log parsing, reading large files, NDJSON pipelines — who wants something smaller and more current than dominictarr's original split.

Built on core Node Transform streams instead of the older streams2-era split, so it behaves correctly with backpressure and modern pipe chains. The maxLength/skipOverflow options are a real-world safety valve against unbounded buffer growth on malformed or missing delimiters, which is the actual failure mode with line-splitting on untrusted input. API is a drop-in replacement for split, so migration is zero-cost. Benchmark numbers are included and show it beating readline.createInterface, with actual methodology disclosed rather than just a claim.

No TypeScript types shipped and none mentioned in the README — if you're in a TS codebase you're reaching for @types/split2 or writing your own. The mapper function isn't wrapped in try/catch (a deliberate departure from the original split), which is a reasonable design choice but will surprise anyone porting from split and not reading the README closely. No mention of encoding handling for multi-byte UTF-8 sequences split across chunk boundaries, which is a classic bug source in line-splitting libraries. Single-file implementation with no architecture docs, so anyone needing to extend it is reading index.js directly rather than following any guide.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →