gio*_*lio 5 javascript functional-programming stream highland.js
我有一个定期从服务器获取数据的 Highland 流。我需要在地图内进行数据库查找。我找不到任何提到在任何 Highland 的变压器中做任何异步的事情。
您可以使用consume异步方式处理流。
_([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]
});
Run Code Online (Sandbox Code Playgroud)