1234567891011121314151617181920 |
- /**
- * Example of a sleep() function without any extra packages.
- *
- * @source https://stackoverflow.com/a/41957152
- */
- async function init() {
- console.log('before sleep');
- await sleep(1000);
- console.log('after sleep');
- }
- function sleep(ms) {
- return new Promise((resolve) => {
- setTimeout(resolve, ms);
- });
- }
- init();
|