我试图让以下片段返回相同的输出 - 数组值流。
第一种方法从数组开始并发出值。
第二种方法将解析数组的 Promise 作为输入,因此它不会发出每个值,而是仅发出数组本身。
我应该在第二种方法中进行哪些更改以使其输出与第一种相同的内容?
const h = require('highland');
var getAsync = function () {
return new Promise((resolve, reject) => {
resolve([1,2,3,4,5]);
});
}
h([1,2,3,4,5])
.each(console.log)
.tap(x => console.log('>>', x))
.done();
//outputs 5 values, 1,2,3,4,5
h(getAsync())
.tap(x => console.log('>>', x))
.done();
//outputs >>[1,2,3,4,5]