New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

image-preload

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-preload

Simple, framework-agnostic image preloader. Async, sync, background, foreground, whatever!

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

image-preload

Simple, framework-agnostic image preloader. Async, sync, background, foreground, whatever!

Installation

npm install --save image-preload

Or you can use a browser script available from https://unpkg.com/image-preload@1.0.6/browser/main.js.

Minimal usage
import Preload from "image-preload";

Preload(["https://i.imgur.com/VCr4saa.png"]);

Async, in background usage

import Preload from "image-preload";

Preload(["https://i.imgur.com/VCr4saa.png"], {
  inBackground: true,
  toBase64: true,
  onSingleImageComplete: base64 => console.log(base64)
});

Sorting options usage

import Preload, { Order } from "image-preload";

Preload(["https://i.imgur.com/VCr4saa.png"], { order: Order.AllAtOnce });
// or
Preload(["https://i.imgur.com/VCr4saa.png"], { order: Order.InOrder });

All options

type Options = {
  order?: Order;
  timeout?: number;
  shouldContinueOnFail?: boolean;
  toBase64?: boolean;
  inBackground?: boolean;
  onSingleImageFail?: Function;
  onSingleImageComplete?: Function;
  onComplete?: Function;
};

Defaul options

const defaultOptions = {
  order: Order.InOrder,
  timeout: 0,
  shouldContinueOnFail: true,
  toBase64: false,
  inBackground: false,
  onSingleImageFail: () => {},
  onSingleImageComplete: () => {},
  onComplete: () => {}
};

Keywords

image

FAQs

Package last updated on 08 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts