Skip to content

Instantly share code, notes, and snippets.

@selcukcihan
Created March 31, 2020 12:56
Show Gist options
  • Save selcukcihan/86d80594edf72b3709987ccff4ca33ec to your computer and use it in GitHub Desktop.
Save selcukcihan/86d80594edf72b3709987ccff4ca33ec to your computer and use it in GitHub Desktop.
Native modül kullanımına örnek
import {DEFAULT_SLEEP_MILLISECONDS, sleep} from './utils.js'
console.log(`${DEFAULT_SLEEP_MILLISECONDS} milisaniye uyuyalım `);
sleep()
.then(_ => {
console.log(`3000 milisaniye uyuyalım `);
return sleep(3000);
});
{
"name": "moduller",
"type": "module"
}
const DEFAULT_SLEEP_MILLISECONDS = 1000;
function sleep(milliseconds) {
return new Promise(resolve =>
setTimeout(resolve, milliseconds || DEFAULT_SLEEP_MILLISECONDS)
);
}
export { DEFAULT_SLEEP_MILLISECONDS, sleep }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment