I am using the highlandjs
library to read files and add an end card to their contents before displaying them in the console:
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);
I would like to use highland.compose
to wrap these into a single function call, I started with:
const readAllFiles = highland.compose(
highland.map,
addEndCard,
readFile
);
readAllFiles(files).parallel(3).each(console.log);
I get the error:
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
It looks like the composed function is not returning a highland stream
.