The problem with the Espruino turning off when the light tries to come on as the batteries get low, the battery voltage is falling below 3.3v and resetting the Espruino. I'd argue that this is just an issue of the batteries running out - What voltage are you getting out of the batteries while they're running the light at that point?
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.
The problem with the Espruino turning off when the light tries to come on as the batteries get low, the battery voltage is falling below 3.3v and resetting the Espruino. I'd argue that this is just an issue of the batteries running out - What voltage are you getting out of the batteries while they're running the light at that point?
Here's the work in progress. It's waiting on images and diagrams (I've got schematics ready, but I I want a diagram of how to wire, and some pictures, before I put in a pull request) https://github.com/SpenceKonde/EspruinoDocs/blob/master/devices/mosfets.md