Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Created November 13, 2017 14:09
Show Gist options
  • Save tanepiper/e7f422ea08429eb9a12f4dfcb7d7060a to your computer and use it in GitHub Desktop.
Save tanepiper/e7f422ea08429eb9a12f4dfcb7d7060a to your computer and use it in GitHub Desktop.
A JS sleep function that can also call a passed function
const sleep = (ms, caller, ...args) => new Promise(resolve => setTimeout(caller || resolve, ms, ...args));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment