Created
April 3, 2020 12:11
-
-
Save selcukcihan/f92fe7f70123be3b9e91be2e960512ff to your computer and use it in GitHub Desktop.
CJS (CommonJS, native olmayan modüller)
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
| { | |
| "name": "moduller" | |
| } |
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) | |
| ); | |
| } | |
| exports.DEFAULT_SLEEP_MILLISECONDS = DEFAULT_SLEEP_MILLISECONDS; | |
| exports.sleep = sleep; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment