Skip to content

Commit

Permalink
add sleep utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamis authored Oct 2, 2018
1 parent 2bf3de5 commit 43187e2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gc/polyfill/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,17 @@ if (!navigator.requestGPIOAccess) {
}

})()

//////////////////////////////////////////////////////////////////////////
// common utility functions

/**
* Utility function for async/await code.
* @param {number} ms - milliseconds to wait
* @return {Promise} A promise to be resolved after ms milliseconds later.
*/
function sleep(ms) {
return new Promise(function(resolve) {
setTimeout(resolve, ms);
});
}

0 comments on commit 43187e2

Please sign in to comment.