caolan / caolan/highland

pipe to writable with parameters

Open
#664 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

Hey there, first: I absolutely love your work, great library! Makes working with streams so much fun and has great inter-op with ramda!

This is more a question than an issue because I couldn't find a better place to ask it:

Is there a idiomatic way to dynamically create write streams and pipe to them, using some derived file name?

Currently I'm doing something like:

``` javascript
const writeFile = ({filename, content}) =>
fs.createWriteStream(filename).write(content)

stream
.map(writeFile)
.done(/* consumes the stream */)
```

However, I'd prefer to simply consume the write stream via `pipe` like:

``` javascript
stream.pipe(writeFile)
```
What would be a better way to do this?

/edit:
And from the [node docs](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback) I can tell my version is not actually safe for writing to the same file in sequence ....

Contributor guide

Open the contributing guide

Research direction

Start by reading Highland's pipe API alongside the Node.js fs.createWriteStream documentation linked in the issue. Compare the requested dynamically named writable streams with the existing stream behavior; completion would require a decided API design and documented expected handling for sequential writes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.