Skip to content

Docs: Add custom delimiter examples to lines.md#1229

Closed
vincent067 wants to merge 2 commits intosindresorhus:mainfrom
vincent067:docs/custom-delimiter-example
Closed

Docs: Add custom delimiter examples to lines.md#1229
vincent067 wants to merge 2 commits intosindresorhus:mainfrom
vincent067:docs/custom-delimiter-example

Conversation

@vincent067
Copy link
Copy Markdown

Hi there! 👋

This PR addresses issue #1210 by adding documentation for using custom delimiters when splitting subprocess output.

What's added

A new "Custom delimiters" section in docs/lines.md with:

  1. Array output with custom delimiter - Shows how to split output by null character (common for filenames with spaces)
  2. Progressive iteration with custom delimiter - A reusable pattern for streaming processing with any delimiter
  3. Common delimiter examples - Ready-to-use transforms for CSV, TSV, and paragraph-separated data

Why this helps

The default newline-based splitting works for most cases, but users often need to process:

  • Null-separated filenames (from find -print0)
  • CSV/TSV data
  • Custom protocol outputs

The examples show how to combine lines: false with objectMode: true transforms to handle these cases.

Bonus fix

Also fixed a tiny syntax error in the iterable() example (had an extra )).

Let me know if you'd like any adjustments! Happy to iterate on this. 😊


Related: Closes #1210

vincent067 added 2 commits March 20, 2026 18:07
Add examples/ directory with four common use cases:
- build-script.js: Build automation with error handling
- git-helpers.js: Programmatic git operations
- parallel-tasks.js: Running commands in parallel
- stream-processing.js: Output filtering and transforms

These examples help new users understand practical usage patterns
beyond the basic documentation.
Add documentation and examples for using custom delimiters when splitting
output, addressing issue sindresorhus#1210. Includes:

- Array output with custom delimiter (null character example)
- Progressive iteration with custom delimiter
- Common delimiter examples (CSV, TSV, paragraph)

Also fixes a minor syntax error in the iterable() example.
@ehmicky
Copy link
Copy Markdown
Collaborator

ehmicky commented Mar 20, 2026

Hi @vincent067,

Thanks for your contribution.

It appears that this PR includes most of #1230, so could you remove the parts already included in the other PR? So we can review them at the same time, as opposed to one after the other?

stdout: {transform: csvTransform, objectMode: true},
})`echo "apple,banana,cherry,date"`;
console.log(items); // ['apple', 'banana', 'cherry', 'date']
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those 3 examples are a little bigger in size and more specific than the other examples in our documentation, which are trying to explain the feature with as few lines as possible.

Would you please move them to the examples directory instead, then include some link to them from lines.md? Thanks!

@ehmicky
Copy link
Copy Markdown
Collaborator

ehmicky commented Mar 21, 2026

Also, please make sure the CI tests are passing. Thanks! :)

@sindresorhus
Copy link
Copy Markdown
Owner

I'm going to close all of this as it's just AI-generated slop seemingly without any human review.

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.

How can I progressively iterate over stdout lines with a custom delimiter

3 participants