The `isomorphic-timers-promises` package provides a unified, promise-based API for handling asynchronous timers (`setTimeout`, `setImmediate`, `setInterval`) across both client-side browser environments and server-side Node.js runtimes. It serves as a polyfill and consistent interface for the `timers/promises` API introduced in Node.js, ensuring that code relying on these promise-returning timer functions works seamlessly regardless of the execution environment. Currently at stable version 1.0.1, the package is relatively new but offers a direct implementation of the Node.js specification, aiming for high compatibility. Its key differentiator is providing this modern timer API in contexts where it's not natively available, specifically browsers, or older Node.js versions, by abstracting away environmental differences. While it currently ships with version 1.0.1, its release cadence is expected to be stable after its initial minor updates.
npm install isomorphic-timers-promisesVerified import paths — ran on the pinned version, not inferred.
Demonstrates asynchronous timer functions (`setTimeout`, `setImmediate`, `setInterval`) that return Promises or async iterators, providing consistent timing across Node.js and browser environments.
Configure your bundler's alias resolver (e.g., `resolve.alias` in Webpack, `@rollup/plugin-alias` in Rollup) to map `'timers/promises'` to `'isomorphic-timers-promises'`.
Do not rely on `options.ref` when targeting browser environments; for client-side code, assume timers always keep the event loop active or use `AbortSignal` for explicit cancellation.
Always use `for await (const value of setInterval(...))` when using `setInterval` to iterate over emitted values in an asynchronous loop.
Add an alias in your bundler configuration (e.g., `webpack.config.js` or `rollup.config.js`) to map `'timers/promises'` to `'isomorphic-timers-promises'`.
Ensure you are using named imports: `import { setTimeout, setImmediate, setInterval } from 'isomorphic-timers-promises';`No dependency data recorded yet.