1.4.1 • Published 10 years ago

images-cache v1.4.1

Weekly downloads
11
License
MIT
Repository
github
Last release
10 years ago

images-cache

npm license github-issues

nodei.co

Cache images as base64 for faster browser display

Features

  • load a bunch of urls and notify progress via a promise
  • store these urls binary content as base64
  • fallback to original url when image not found in cache

:warning: As images are downloaded via AJAX, the remote urls must have CORS enabled

QuickStart

import imagesCache from 'images-cache';

const images = [
  'http://path/to/image.jpg',
  'http://path/to/image2.jpg'
];

imagesCache.load(images).progress(status => {
  console.log('progress', status.loaded, status.total);
}).then(() => {
  imagesCache.get('http://path/to/image.jpg'); // -> returns the base64 version, ex: data:image/jpg;base64,...
  imagesCache.get('http://path/to/unknown/image.jpg'); // -> returns 'http://path/to/unknown/image.jpg'
}).done();

API

  • load(urls): load a bunch of urls and store internally as base64.
  • get(url): return base64 version of an existing url, and return original url if not found in cache
  • clear(): empty the current cache

Scripts

  • npm run readme : node ./node_modules/node-readme/bin/node-readme.js
  • npm run test : find ./spec -iname '*.spec.js' -exec ./node_modules/.bin/babel-node {} \; | ./node_modules/.bin/tap-spec
  • npm run build : ./node_modules/.bin/browserify ./src/index.js -o ./dist/index.js
  • npm run watch : ./node_modules/.bin/watchify ./src/index.js -o ./dist/index.js

Dependencies

PackageVersionDev
browser-request0.3.3
q1.4.1
babel5.6.23
babel-eslint3.1.23
babelify6.1.2
browserify11.0.1
eslint1.0.0-rc-1
eslint-config-airbnb0.0.6
mockery1.4.0
node-readme0.1.8
tap-spec4.0.2
tape4.0.0
watchify3.3.1

Author

Julien Bouquillon julien@bouquillon.com undefined

License

1.4.1

10 years ago

1.4.0

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago