caolan / caolan/highland

processing highland stream chunks using async

Open
#543 22 comments 0 reactions 0 assignees View on GitHub
cookbook
Dominant language
JavaScript
Stars
3.4k
Forks
145
PR merge metrics
No merged PRs in 30d

Description

I'm using highland.js to process a file using a stream to read the contents between two delimiters. I'm also using async.js to run a series of http requests in sequence.

Ideally I would like to pass the output x from highland as the first function to the async series (chain) so that the HTTP requests get executed for each chunk extracted from the stream.

Is this possible? If so, how can this be achieved?

``` javascript
var async = require('async');
var _ = require('highland');

_(fs.createReadStream(files[0], { encoding: 'utf8' }))
.splitBy('-----BEGIN-----\n')
.splitBy('\n-----END-----\n')
.filter(chunk => chunk !== '')
.each(function (x) {
}).done(function () {

async.series([
function(callback) {
setTimeout(function() {
console.log('Task 1');
callback(null, 1);
}, 300);
},
function(callback) {
setTimeout(function() {
console.log('Task 2');
callback(null, 2);
}, 200);
},
], function(error, results) {
console.log(results);
});

});;
```

Contributor guide

Open the contributing guide

Research direction

Start with the Highland stream chain and the async.series example shown in the issue. Determine whether the requested per-chunk sequencing is supported by the existing APIs; the payload names no repository files or tests, so completion would require defining the expected behavior before implementation or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
stream-processing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.