Working example of how to create timers in JavaScript?

Anyone out there that have working JavaScript examples of how to use/create timers in rules? I am trying to translate my old DSL timers (that can be restarted) to OH 3 JavaScript rules. I have found short code snippets here and there but there are always some important part missing to get it running.


Without starting a new post for a simple question,
There is no way to pass timers from one rule to the next at the moment is there?

Ive resorted to using a text.rules file for my garage which cancels the timers for lights to turn off if i switch the light off and on again myself.

Theoretically there might be a way using Script Extensions. But I don’t know how to use them yet.