【发布时间】:2016-02-29 21:54:30
【问题描述】:
我正在使用highlandjs 库来读取文件并在其内容中添加结束卡,然后在控制台中显示它们:
const readFile = highland.wrapCallback(fs.readFile);
const addEndCard = x => x + '\nx---THE END---x\n';
files.map(readFile).parallel(3).map(addEndCard).each(console.log);
我想使用highland.compose 将它们包装到一个函数调用中,我开始使用:
const readAllFiles = highland.compose(
highland.map,
addEndCard,
readFile
);
readAllFiles(files).parallel(3).each(console.log);
我得到错误:
TypeError: readAllFiles(...).parallel is not a function
at Object.<anonymous> (/home/vamsi/Do/highland-fun/index.js:14:21)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:18)
at node.js:980:3
看起来组合函数没有返回highland stream。
【问题讨论】:
标签: node.js function-composition highland.js