Closed jadonk closed 4 years ago
Why break the API?
From @mvduin on April 24, 2018 5:3
No need to break the API, you can just use callback.length to continue to support the old callback style for backwards compatibility in addition to the node.js standard callback style (which is required e.g. to be able to use util.promisify).
Note that only a few functions need this anyway. Most functions in bonescript (e.g. everything to do with gpio, pwm, and pinmux) are purely cpu-bound operations and using callbacks for them instead of using the synchronous versions accomplishes absolutely nothing besides making the code less efficient and harder to understand. Using callbacks for these should be entirely deprecated.
From @psiphi75 on April 24, 2016 0:4
Currently bonescript uses value-only callbacks. I would like to make a feature request that uses node-style callbacks. This is the standard way that node uses callbacks.
I am glad to implement these changes. But I would like your approval / comments before continuing.
Below is some existing sample code from hw_mainline.js, it shows that the fs.readFile uses node-style callback, while bonescript converts this to a value-only callback.
Below I suggest a way to migrate to node-style callbacks. Since this is likely a breaking change for many applications I have built in a warning message. This method has the following features:
The difference is usage.
Copied from original issue: jadonk/bonescript#124