File size: 372 Bytes
450060f
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export async function loadImage(image: string): Promise<HTMLImageElement> {
  const img = new Image();
  img.src = image;

  const imgOnLoad = () => {
    return new Promise<HTMLImageElement>((resolve, reject) => {
      img.onload = () => { resolve(img) };
      img.onerror = (err) => { reject(err) };
    })
  };

  const loadImg = await imgOnLoad();
  return loadImg
}