-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
discussIssues opened for discussions and feedbacks.Issues opened for discussions and feedbacks.
Description
- Version: -
- Platform: -
- Subsystem: -
I want to discuss the code style of arrow function in Node.js source code.
Maybe most of you think that =>
can replace all of anonymous callback functions. So Node.js source code includes lots of arrow functions. e. g.
// _http_agent.js
nextTick(asyncId, () => ...);
// _http_client.js
req.once('response', (res) => {
etc.
But IMHO, I think arrow function should only use in some situation that the function is just used as a inline lambda expression even though they have a very convenient feature - value of this
. That means arrow function should not be misused. And anonymous function should used as callback (mainly asynchronous) or listener functions.
So that's my opinion:
array.map([ ... ], val => { /* do some thing */ });
array.reduce([ ... ], (ans, val) => { ... }, {});
req.on('response', function() {
// do something
});
fs.readFile(filename, function() {
// do something
});
I think we can discuss with this and if my opinion is acceptable, I can start working with modifying the style.
Metadata
Metadata
Assignees
Labels
discussIssues opened for discussions and feedbacks.Issues opened for discussions and feedbacks.