fi

fetch-images

Fetch images function

Showing:

Popularity

Downloads/wk

1

GitHub Stars

0

Maintenance

Last Commit

6yrs ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.4KB

License

MIT

Type Definitions

Tree-Shakeable

Yes?

Categories

Readme

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(...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";

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial