Check this thread out, I believe this user formalised some code for exactly this and shared it
http://forum.espruino.com/conversations/285086/#comment13000674
@Ollie started
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.
Check this thread out, I believe this user formalised some code for exactly this and shared it
http://forum.espruino.com/conversations/285086/#comment13000674