🌳 Tree-shakable |
📦 Zero runtime dependencies |
🧪 No global monkey-patching |
🛡️ Type-safe
⏱️ Deterministic timers |
🕓 Four clock strategies |
🌍 Real timezone support (when applicable) |
🔌 Bring your own date library
Time is a dependency
Code coupled to the native Date object, Temporal objects, any specific date library, or the
environment's scheduler (setTimeout, setInterval) has an implicit
dependency on the system clock. That's what pushes teams toward global
fake-timer libraries for testing - patching Date/timers process-wide,
which affects unrelated code and makes tests harder to reason about.
vs. jest.useFakeTimers() / sinon.useFakeTimers(): scoped per call site, no global patch, no restore/cleanup step.
time-provider makes time an explicit, injectable dependency instead: a
single object exposing a clock, a parser, and a scheduler, swappable per
call site.
Features
Four clock strategies: system (real time), fixed, manual (advance time explicitly), sequential (predefined instants) - same API for production and tests.
Deterministic timers: setTimeout/setInterval driven by the clock strategy, not the real event loop, so manual/sequential/fixed runs are synchronous and don't depend on wall-clock time.
Real timezone support where the underlying library allows it (native Date, plain Moment.js are UTC-only - see ARCHITECTURE.md) - withLocalTimezone(...) plus localNow()/utcNow().
Tree-shakable: no deterministic runtimes bundled when not imported.
Manual and sequential clocks run synchronously. A due setTimeout/setInterval callback fires in-line, as a direct side effect of the call that made it due (advance(), localNow(), utcNow()) - not on a real event-loop tick. This is what makes them deterministic without await, but it means call ordering can differ subtly from a real async run.
Learn more
ARCHITECTURE.md - how the packages fit together, the plugin/adapter model, why native Date and plain Moment.js are UTC-only.
CONTRIBUTING.md - development setup, workflow, reporting bugs/features.
BENCHMARK.md - faster than jest/sinon fake timers.
Per-package README (packages/<name>/README.md) for adapter-specific notes.
CHANGELOG.md - changes log from the core library and all plugins.
The npm package @time-provider/core receives a total of 0 weekly downloads. As such, @time-provider/core popularity was classified as not popular.
We found that @time-provider/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.