doc: modernize code examples in the cluster.md#10270
doc: modernize code examples in the cluster.md#10270vsemozhetbyt wants to merge 7 commits intonodejs:masterfrom vsemozhetbyt:cluster.md
Conversation
It also will be consistent with a previous code example.
doc/api/cluster.md
Outdated
There was a problem hiding this comment.
Can you use "started"? There is an online event, and this isn't it.
doc/api/cluster.md
Outdated
There was a problem hiding this comment.
this is worse than original
There was a problem hiding this comment.
@sam-github Should I also change the prototype into the for...in variant?
`cluster.workers` iteration: `Object.keys().forEach` -> `for`...`in`
|
LGTM, should be squashed before landing. |
| } | ||
|
|
||
| Object.keys(cluster.workers).forEach((id) => { | ||
| for (const id in cluster.workers) { |
There was a problem hiding this comment.
Nit: I think it's better to keep Object.keys here? for...in also includes non own enumerable properties.
There was a problem hiding this comment.
Nvm for...in is also used below.
There was a problem hiding this comment.
There are no such properties in cluster.workers.
There was a problem hiding this comment.
Yes I know, but I think the intention is to also educate in examples?
There was a problem hiding this comment.
Yes, this example educates that there are no such properties, that cluster.workers is a vanilla js object underived from anything, and doesn't require complex boiler plate safe-guards to be used.
|
ping @nodejs/documentation |
|
Landed in e03ee71 |
Checklist
Affected core subsystem(s)
doc, cluster
Description of change
var->let/const==->===cluster.workersiteration:Object.keys().forEach->for...inFixes: #10255