Created
September 21, 2019 10:32
-
-
Save Odepax/4d4d50ac4c1ecf38f900e42ec7a2d622 to your computer and use it in GitHub Desktop.
Javascript Promise.delay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Returns a promise that resolves after 'timeout' ms. */ | |
Promise.delay = function delay(/** @type {number} @description Unit: ms. */ timeout, value = undefined) { | |
return new Promise(resolve => setTimeout(() => resolve(value), timeout)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment