Closed wujekbogdan closed 5 years ago
@wujekbogdan Thanks for opening the issue.
If you want to use arrow functions, we don't need to pass the stream to the callback. You already will have a reference to the stream -- in your example, this
is a reference to feedParser
.
So, you could write:
feedParser.on("readable", (stream) => {
let item;
while (item = feedParser.read()) {
if (argv.group) {
items.push(item);
}
else {
if (argv.json) {
console.log(JSON.stringify(item));
}
else {
console.log(util.inspect(item, null, 10, true));
}
}
}
});
Currently it's not possible to use arrow functions for callbacks because we have to access
stream
reference viathis
:It would be great if the reference to
stream
was passed as an argument to the callback function, so that we could use arrow functions as follows: