serial protocol does not have something like connection established or closed... At best, you could go after rts / cts like in RS-232, even though this just means that participating device signals to be ready to receive or transmitt. In the old days with modems over phone lines there was the cd - carrier detect - that could have been used. But in a direct serial connection this is not possible.
I you can make assumptions about your participating devices by monitoring your RX line: you may recognize the first going high as becoming available or already being high when initializing, which means: vis-a-vis has valid idle signal on TX line established. Corollary, a going low for a longer time as start bit and byte transmission means: sending vis-a-vis stopped maintaining valid idle signal on TX line. Watching the RX line this way is usually not done, since the serial reception appliance has usually already built-in error detection: start-bit too long, stop-bit never showing, parity failed, over and under runs, etc... These issues result in flags you can check. Issues beyond that are then usually caught in the application protocol, when needed, such as with ACK, NACK, etc.
So you are out of luck and the bare metal for serial... but you can think of a (periodic) ping... poll if vis-a-vis is still there and responding... does though not guarantee that on the next communication attempt vis-a-vis is still there.
What are you trying to achieve? What is the application situation?
Does Espruino trigger any events related to new connections via Serial/USB ?
According to the Espruino Original documentation, the only event available is