I have a Highland stream that is periodically getting data from a server. I need to do a database lookup inside of a map. I can't find any mention of doing anything async in any of Highland's transformers.
You can use consume to process a stream in an async manner.
_([1, 2, 3, 4]).consume(function(err, item, push, next) {
  // Do fancy async thing
  setImmediate(function() {
    // Push the number onto the new stream
    push(null, item);
    // Consume the next item
    next();
  });
})).toArray(function(items) {
  console.log(items); // [1, 2, 3, 4]
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With