It's for the website, but that way of working can go equally well when trying to build a module in.
But yes, the main thing is anything you want to access directly should just be exports.xyz = ....
One other thing to note: If you're trying to do arrays in a built-in module, try and do them inside a function where possible:
exports.getMyArray = function() { return [....] }; stores the function text in flash until it's executes, but exports.myArray = [....]; will put the array in RAM as soon as you first call require(...) and will keep it there
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.
There's some info on making modules here: http://www.espruino.com/Writing+Modules
It's for the website, but that way of working can go equally well when trying to build a module in.
But yes, the main thing is anything you want to access directly should just be
exports.xyz = ...
.One other thing to note: If you're trying to do arrays in a built-in module, try and do them inside a function where possible:
exports.getMyArray = function() { return [....] };
stores the function text in flash until it's executes, butexports.myArray = [....];
will put the array in RAM as soon as you first callrequire(...)
and will keep it there