Reading the source of the function mapassociated with http://highlandjs.org/#map , you can see that the function is applied as follows:
var fnVal, fnErr;
try {
fnVal = f(x);
} catch (e) {
fnErr = e;
}
push(fnErr, fnVal);
so if you want to convert a value to a streaming StreamError using a transformer map, you need to throw an error.
The following code:
var _ = require('highland');
var accounts = ['ack', 'bar', 'foo'];
_(accounts).map(function (x) {
throw new Error(x);
}).errors(function (err, push) {
push(null, 'fark');
}).each(function (x) {
console.log(x);
});
will give you the expected
fark
fark
fark
source
share