Why would you use a .connect() function / method to create a Rodrigues instance?
I know hat this pattern is typical for connecting devices. But in this case, it is just a transformer, isn't?
To return a constructor function in a require, just set the exported object to it: exports = Rodrigues;.
If you want to stick with the pattern, you can return exports.getInstance = function() { return new Rodrigues(); } to provide a self documenting function.
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.
Why would you use a
.connect()
function / method to create a Rodrigues instance?I know hat this pattern is typical for connecting devices. But in this case, it is just a transformer, isn't?
To return a constructor function in a require, just set the exported object to it:
exports = Rodrigues;
.If you want to stick with the pattern, you can return
exports.getInstance = function() { return new Rodrigues(); }
to provide a self documenting function.