The code is here. You're interested in files named: mockTheClock.js and wrapped-date.js. It is inspired by equivalent code in JSUnit, but it's more full featured and more efficient. In particular I'm using binary heap to order pending timers.
The code is Apache-licensed, so feel free to grab and re-use it for your own projects.
The code is Apache-licensed, so feel free to grab and re-use it for your own projects.