Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite utils/throttle #112

Open
JohnPaulHarold opened this issue Aug 18, 2023 · 0 comments
Open

rewrite utils/throttle #112

JohnPaulHarold opened this issue Aug 18, 2023 · 0 comments
Labels

Comments

@JohnPaulHarold
Copy link
Owner

If we are to keep the throttle function, it should be rewritten to return a wrapped function, as opposed to the current implementation.

Something like

const throttle = (fn, delay) => {
  let last = 0;
  return (...args) => {
    const now = new Date().getTime();
    if (now - last < delay) {
      return;
    }
    last = now;
    return fn(...args);
  };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant