AugurProject/augur-ui

View on GitHub
src/utils/debounce.js

Summary

Maintainability
A
0 mins
Test Coverage
export default function debounce(func, wait) {
  let timeout;
  const realWait = wait || 250;

  return (...args) => {
    const context = this;

    const later = () => {
      timeout = null;
      func.apply(context, args);
    };

    clearTimeout(timeout);
    timeout = setTimeout(later, realWait);
  };
}