Twelve lines covering the case most projects add a dependency for, including cancelling a call that has not fired yet.
Language
Snippets written in Javascript
Runs at most once per interval but still fires once more after the last event, so the final state is never dropped.
Object.groupBy is available in current runtimes; the reduce version is the fallback for older ones.
Backs off on each failure and adds jitter, so a recovering service is not hit by every client at the same moment.
fetch has no timeout of its own. AbortSignal.timeout is the short way to give it one.
Keeps a fixed number of jobs in flight rather than firing a thousand requests at once.
structuredClone handles Dates, Maps, Sets and cycles, which JSON round-tripping quietly destroys.
Intl handles the symbol, the separators and the decimal places for the locale, so you never hand-roll them.
Turns a timestamp into 'three days ago' using the built-in formatter.
The modern API needs a secure context and a real user gesture, so the failure path matters as much as the success one.
A plain === leaks how much of the token matched through its timing. This does not.
The handful worth setting even when you are not using a framework that sets them for you.