The new TypeScript library, '@alsoftworks/temporize', has been introduced to offer strongly typed timing and concurrency utilities. This library focuses on controlling the execution frequency and timing of functions, providing tools like debounce and throttle.
A key feature of '@alsoftworks/temporize' is that every scheduled call returns a real Promise for the wrapped function's actual result. The library has no runtime dependencies and is distributed as both ESM and CommonJS modules. It includes functionalities for debouncing, throttling, batching, retry timing, frame scheduling, and idle scheduling.
The library's debounce and throttle implementations are Promise-aware. For example, multiple coalesced calls to a debounced function each receive a separate Promise that settles with the result of the single invocation. A leading-only debounce resolves suppressed calls with the leading invocation's result. Similarly, throttling coalesces excess calls and uses the latest arguments for a trailing invocation.
Specific utilities include `debounce`, `throttle`, `rafThrottle`, and `debounceAsync`. The `rafThrottle` utility uses `requestAnimationFrame` in browsers and falls back to a 16ms `setTimeout` in SSR environments or Node.js, ensuring safe usage where animation-frame globals are not present. `debounceAsync` supports `AbortSignal` for managing asynchronous operations.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
A new TypeScript library, '@alsoftworks/temporize', has been released, providing strongly typed utilities for debouncing, throttling, and other timing controls. This library is designed to manage when and how often functions execute, returning Promises for the wrapped function's results.