▶️ API | Info | redux-time | Example | Source
Simple Javascript library that provides an equivalent to Date.getTime()
with variable progression speed.
It has a hook to receive timestamps and estimated latency, which it uses to stay in sync with a backend server's time.
yarn add warped-time # ⏱
For more details and usage examples see docs on redux-time
.
API
windowtime = windowstore 1// takes: optional redux store, initial_speed, initial_timestamp windowtime> 1499014500windowtime> 1499014500 windowtime // make time start going backwards at -1x windowtime> 1499014501windowtime> 1499014499 windowtime // make time progress at 0.01x its actual speed windowtime> 149901449901 const server_time = timestamp_from_server + rtlatency/2windowtime // set time to the server time instantly windowtime // sync to server time over 1000ms
Info
This library is useful for:
- time-travel debugging
- animations
- any situation where you want a version of time that's flowing slower/faster/reversed compared to the actual time
- keeping a front-end time in sync with a backend time
- real-time games
We use it for time-travel debugging and animation timing sync in our library redux-time
.

MIT License | Monadical SAS 2017 (we're hiring!)