-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to convert array into individual values? #619
Comments
If you want to convert each array into a single object, use highland(myArray)
.map(page => highland(download(page))
.parallel(5)
// This will flatten the arrays from download into multiple individual values.
// Each one will be fed into handleSingleObject.
.flatMap(_)
.pipe(handleSingleObject())
... |
Thanks! The documentation for await new Promise((resolve, reject) => {
highland(myArray)
.map(page => highland(download(page)))
.mergeWithLimit(5)
.sequence()
.stopOnError(reject)
.pipe(handleSingleObject())
.pipe(fs.createWriteStream(someFile))
.on('finish', resolve)
.on('error', reject)
}) Also I noticed something interesting. If I replace |
Sequence will work just as well for arrays.
It doesn't throw, because When you use const stream = highland()
...
.flatMap(() => stream)
... I'm not sure what happens in this situation. You'll probably end up with a deadlock, where your promise never resolves. |
In this code,
download
returns an array of many objects, buthandleSingleObject
expects a single object to be piped through it. Is there a way to convert an array of objects into a single object for piping further down the chain?The text was updated successfully, but these errors were encountered: