Skip to main content

Debounce Async

MIDDLE

Debounce Async

Create a debounced version of an async function.

Requirements:

  • Implement debounceAsync that wraps an async function
  • Delay execution until after wait milliseconds have passed since last call
  • Return a Promise that resolves with the result

Example:

const searchAPI = async (query) => {
  return `Results for: ${query}`;
};

const debouncedSearch = debounceAsync(searchAPI, 300);
debouncedSearch('abc'); // Only this executes

Examples:

Input 1:{"wait":100,"calls":[1,2,3]}
Output 1:6

Loading editor...

Run your code to see results

Click the Run button above