Repository: expo/expo
File: packages/expo-image/src/Image.types.ts (TypeScript)

Code before:
  loadAsync(source: ImageSource, options?: ImageLoadOptions): Promise<ImageRef>;
}

/**
 * An object with options for the [`useImage`](#useimage) hook.
 */
export type ImageLoadOptions = {
  /**
   * If provided, the image will be automatically resized to not exceed this width in pixels, preserving its aspect ratio.
   */
  maxWidth?: number;

  /**
   * If provided, the image will be automatically resized to not exceed this height in pixels, preserving its aspect ratio.
   */
  maxHeight?: number;

  /**
   * Function to call when the image has failed to load. In addition to the error, it also provides a function that retries loading the image.
   */
  onError?(error: Error, retry: () => void): void;
};

/**
 * An object containing options for the [`configureCache`](#configurecacheconfig) function.
 * See [SDImageCacheConfig](https://sdwebimage.github.io/documentation/sdwebimage/sdimagecacheconfig) for more information.
 * @platform ios
 */
export type ImageCacheConfig = {
  /**
   * The maximum size of the disk cache, in bytes.
   * Defaults to 0, which means there is no cache size limit.
   */
  maxDiskSize?: number;

  /**
   * The maximum “total cost” of the in-memory image cache. The cost function is the bytes size held in memory.
   */
  maxMemoryCost?: number;

  /**
   * The maximum number of objects the in-memory image cache should hold.
   * Defaults to 0, which means there is no memory count limit.
   */
  maxMemoryCount?: number;
};


Review comment (performance):
```suggestion
 * See [`SDImageCacheConfig`](https://sdwebimage.github.io/documentation/sdwebimage/sdimagecacheconfig) for more information.
```

Code after:
  loadAsync(source: ImageSource, options?: ImageLoadOptions): Promise<ImageRef>;
}

/**
 * An object with options for the [`useImage`](#useimage) hook.
 */
export type ImageLoadOptions = {
  /**
   * If provided, the image will be automatically resized to not exceed this width in pixels, preserving its aspect ratio.
   */
  maxWidth?: number;

  /**
   * If provided, the image will be automatically resized to not exceed this height in pixels, preserving its aspect ratio.
   */
  maxHeight?: number;

  /**
   * Function to call when the image has failed to load. In addition to the error, it also provides a function that retries loading the image.
   */
  onError?(error: Error, retry: () => void): void;
};

/**
 * An object containing options for the [`configureCache`](#configurecacheconfig) function.
 * See [`SDImageCacheConfig`](https://sdwebimage.github.io/documentation/sdwebimage/sdimagecacheconfig) for more information.
 * @platform ios
 */
export type ImageCacheConfig = {
  /**
   * The maximum size of the disk cache, in bytes.
   * Defaults to 0, which means there is no cache size limit.
   */
  maxDiskSize?: number;

  /**
   * The maximum "total cost" of the in-memory image cache. The cost function is the bytes size held in memory,
   * not simply the pixel count. For example, a typical ARGB8888 image uses 4 bytes (32 bits) per pixel.
   * Defaults to 0, which means there is no memory cost limit.
   */
  maxMemoryCost?: number;

  /**
   * The maximum number of objects the in-memory image cache should hold.
   * Defaults to 0, which means there is no memory count limit.
   */
  maxMemoryCount?: number;
};