Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created February 25, 2020 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/ed5da9df0144fdbd2d214b4760406443 to your computer and use it in GitHub Desktop.
Save yairEO/ed5da9df0144fdbd2d214b4760406443 to your computer and use it in GitHub Desktop.
mock async AJAX request
const mockAjax = (timeout => (RES, duration) => {
clearTimeout(timeout); // abort last request
return new Promise((resolve, reject) => timeout = setTimeout(resolve, duration || 0, RES))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment