If we interpret "idiomatic Node" as "what Node itself does", then null
would be what is idiomatic. If you type this at the Node prompt (on a *nix machine), you'll get true
:
require("fs").readFile("/dev/null", function (err) { console.log(err === null) })
I've tried with other callbacks from the fs
module and got the same behavior. I've not tested all places in Node's API where callbacks are used.
I've not found a reference that states that Node must set err
to null
in such cases.