Skip to content

Instantly share code, notes, and snippets.

@kayac-chang
Created September 7, 2019 07:38
Show Gist options
  • Save kayac-chang/ff1de1e4b48e7285320ee9ae20ecf199 to your computer and use it in GitHub Desktop.
Save kayac-chang/ff1de1e4b48e7285320ee9ae20ecf199 to your computer and use it in GitHub Desktop.
Throttle by async function call
function throttleBy(func) {
let skip = false;
return async function call(...args) {
if (skip) return;
skip = true;
const result = await func(...args);
skip = false;
return result;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment