You could try something like envjs (https://github.com/smparkes/env-js) or try to pull the timer code from there.
setTimeout is part of the browser environment, not part of javascript.