So you may not even have to change the file, you can do connection = Puck.connect() to get the connection, then connection.device.addEventListener... and connection.reconnect()
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.
Sorry, it looks like that's not implemented in UART.js, however you could look at using the Puck.js library which is very similar.
In it there is a
connection.reconnect
method which should do what you need:https://github.com/espruino/EspruinoWebTÂools/blob/master/puck.js#L236
So you may not even have to change the file, you can do
connection = Puck.connect()
to get the connection, thenconnection.device.addEventListener...
andconnection.reconnect()