Skip to content

Instantly share code, notes, and snippets.

@irrationnelle
Created January 17, 2020 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irrationnelle/ec3cc48f4ab66aef2806a5eb95490377 to your computer and use it in GitHub Desktop.
Save irrationnelle/ec3cc48f4ab66aef2806a5eb95490377 to your computer and use it in GitHub Desktop.
const imgArray = [img1, img2, img3];
// 이 함수는 이미지 크기나 종류에 따라 각기 다른 연산 시간을 가지는 작업을 하는
// Promise 를 리턴한다.
function asyncFun(img) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(img)
}, getRandomArbitrary(100, 1000));
});
}
// 이 함수는 min과 max 사이의 랜덤값을 반환한다
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment