Highland.js and something like busboy
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
It is easy to wrap simple EventEmitter or ReadableStream, but how should I work with something like [busboy](https://github.com/mscdex/busboy). It doesn't implement ReadableStream interface. I finished with code below, but it doesn't look idiomatic:
```
H(function(push) {
busboy.on('file', (fieldname, file, filename, encoding, mimetype)=> {
let saveTo = path.resolve(mediaPath, "#{name}#{extension}")
file.pipe(fs.createWriteStream(saveTo))
push(null, {
[fieldname]: { filename }
})
})
busboy.on('field', (key, value, keyTruncated, valueTruncated) => {
push(null, {[key]: value})
})
busboy.on('finish', () =>
push(null, H.nil)
)
})
.reduce({}, _.extend)
.apply(// do something with form data
```
[The Same question on StackOverflow](http://stackoverflow.com/posts/33926718/edit)
Contributor guide
Assessment
This issue has not been assessed yet.