Skip to content

v2.0.0

Latest

Choose a tag to compare

@mourner mourner released this 07 Oct 13:10

Breaking changes

  • ESM-only. Use import split from 'binary-split'. require('binary-split') still works and returns the function directly, through Node's built-in require() of ES modules.
  • Requires Node 20.19+ or 22.12+.
  • The default delimiter is now '\n' on all platforms. It was os.EOL, which is '\r\n' on Windows. If you relied on that, pass '\r\n' explicitly.
  • Lines are always emitted separately. The readable side is now in object mode, so .read(), for await and stream.toArray() no longer merge lines together.
  • An empty splitOn now throws. Before, it caused an infinite loop.

Improvements

  • Faster: 2–10× on typical line lengths thanks to native Buffer#indexOf. Multi-byte delimiters like '\r\n' gain the most.
  • Linear time for long lines: a line spanning many chunks is now copied once instead of on every chunk. A 50MB line takes 8ms, down from 3.3s.
  • No runtime dependencies: through2 was replaced with Node's built-in stream.Transform.
  • TypeScript types are now included.