Function
11 snippets
Debounce
VerifiedDelays a function until calls stop for N ms. Includes cancel() and flush().
Memoize
VerifiedCaches a function's results by its arguments, with an optional custom cache key.
Once
VerifiedCreates a function that runs only once and returns the first result on later calls.
Retry with Backoff
VerifiedRetries an async function with exponential backoff and jitter, with an optional stop condition and AbortSignal.
Sleep
VerifiedPromise-based delay with optional AbortSignal cancellation.
Throttle
VerifiedRuns a function at most once per N ms, with a trailing call so the last update is never lost.
Compose Functions
Composes multiple functions into a single function, where the output of one function becomes the input of the next.
Curry Function
Transforms a function into its curried form.
Get Contrast Color
Returns either black or white text color based on the brightness of the provided hex color.
Rate Limit Function
Limits how often a function can be executed within a given time window.
Repeat Function Invocation
Invokes a function a specified number of times.