2cts: I would not call the parm in the callback err. I'd rather call it somthing like status or info or ...
If returning 0 (zero), or null, or undefined as the only ok values, that works with easy check of negation. If something bad happened, an error object should be returned if there is more information than just a scalar. Returning a simple scalar for error and having to go back and ask for the error is an option, but it costs memory, if the error is not already an anyway-available status property.
Furthermore, I'd prefer an object over a list of parameters.
My comments should be taken with the grain of Espruino salt, because for a resource tight environment other considerations than just object-orientation apply.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
2cts: I would not call the parm in the callback
err
. I'd rather call it somthing likestatus
orinfo
or ...If returning
0
(zero), ornull
, orundefined
as the only ok values, that works with easy check of negation. If something bad happened, an error object should be returned if there is more information than just a scalar. Returning a simple scalar for error and having to go back and ask for the error is an option, but it costs memory, if the error is not already an anyway-available status property.Furthermore, I'd prefer an object over a list of parameters.
My comments should be taken with the grain of Espruino salt, because for a resource tight environment other considerations than just object-orientation apply.