Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function download(file){
- return new Promise(resolve => {
- console.log(`started downloading ${file.name}`)
- setTimeout(() => {
- console.log(`downloaded ${file.name} in ${file.downloadTime}ms`);
- resolve();
- },file.downloadTime);
- })
- }
- const file = new File('example',2000)
- download(file).then(_ => console.log('complete'))
- // ----- output in console -----
- // started downloading example ...(immediately)
- // downloaded example in 2000ms ...(after 2s)
- // complete ...(after 2s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement