Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-images

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-images

Function for preloading images

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Fetch images function

Function for preloading images.

Your request fetchImages with the array of links of images or HTMLImageElement. fetchImages is resolve, if all images are downloaded successfully. If one of the image will be broken, fetchImages rejects.

Usage

import fetchImages from "fetch-images";

let img = new Image();

const images = [
  "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Edvard_Munch_-_The_dance_of_life_%281899-1900%29.jpg/1920px-Edvard_Munch_-_The_dance_of_life_%281899-1900%29.jpg",
  img
];

const failImages = [
  "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/The_Scream.jpg/800px-The_Scream.jpg",
  'blah'
];

fetchImages(images)
  .then(values => {
    values.map(value => console.log(value));
  })
.catch(err => console.log(err));

fetchImages(failImages)
  .then(values => {
    values.map(value => console.lol(value));
  })
.catch(err => console.log(err));

img.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/The_Scream.jpg/800px-The_Scream.jpg";

FAQs

Package last updated on 29 Feb 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc