While this can be done easily with hardware, a software equivalent could be used. While I can't speak for whether this will work in your case, this implementation (non Espruino though) seems to be what you are after. When the watchdog function is not called, it triggers a separate event, such as a reset.
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.
Wed 2017.08.02
@user79451 have you considered a watchdog timer?
While this can be done easily with hardware, a software equivalent could be used. While I can't speak for whether this will work in your case, this implementation (non Espruino though) seems to be what you are after. When the watchdog function is not called, it triggers a separate event, such as a reset.
https://gist.github.com/rsbohn/1359687
Keep us posted on your success.
Robin