JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "load-image.ts"

Full Path: /home/markqprx/iniasli.pro/client/utils/http/load-image.ts
File size: 744 bytes
MIME-type: text/html
Charset: utf-8

/**
 * Load image avoiding xhr/fetch CORS issues. Server status can't be obtained this way
 * unfortunately, so this uses "naturalWidth" to determine if the image has been loaded. By
 * default, it checks if it is at least 1px.
 */
export const loadImage = (
  src: string,
  minWidth = 1
): Promise<HTMLImageElement> =>
  new Promise((resolve, reject) => {
    const image = new Image();
    const handler = () => {
      // @ts-expect-error
      delete image.onload;
      // @ts-expect-error
      delete image.onerror;
      if (image.naturalWidth >= minWidth) {
        resolve(image);
      } else {
        reject('Could not load youtube image');
      }
    };
    Object.assign(image, {onload: handler, onerror: handler, src});
  });