Created
April 3, 2020 12:25
-
-
Save selcukcihan/75fbca9c0238aad3eca6e256ab0ae03b to your computer and use it in GitHub Desktop.
CJS (CommonJS, native olmayan modüller) alternatif kullanım
This file contains hidden or 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
const utils = require('./utils.js'); | |
console.log(`${utils.DEFAULT_SLEEP_MILLISECONDS} milisaniye uyuyalım `); | |
utils.sleep() | |
.then(_ => { | |
console.log(`3000 milisaniye uyuyalım `); | |
return utils.sleep(3000); | |
}); |
This file contains hidden or 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
const DEFAULT_SLEEP_MILLISECONDS = 1000; | |
function sleep(milliseconds) { | |
return new Promise(resolve => | |
setTimeout(resolve, milliseconds || DEFAULT_SLEEP_MILLISECONDS) | |
); | |
} | |
module.exports = { | |
DEFAULT_SLEEP_MILLISECONDS: DEFAULT_SLEEP_MILLISECONDS, | |
sleep: sleep | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment