npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

image-manager

v1.0.0

Published

Download image manager plus cache manager.

Downloads

1

Readme

Image Manager

Download image manager plus cache manager.

Require in Node

var imageManager = require("image-manager");

API

cacheAdd (image: ImageElement|{element: ImageElement}|String): Object

imageManager.cacheAdd('http://to.some/image.img');
// or
imageManager.cacheAdd($('#myImage').get(0));
// or
var image = new Image;
image.setAttribute(src, 'http://to.some/image.img');
imageManager.cacheAdd(image);
// or
var image = new Image;
image.setAttribute(src, 'http://to.some/image.img');
imageManager.cacheAdd({
	element: image,
	timestamp: 1430155235645
});

Add image to list, put it into cache.

cacheClear ()

Clear cache from all images.

cacheGet (src: String): boolean|Object
imageManager.cacheGet("http://to.some/image.img");
//  →  Object {element: Image, timestamp: 1430155235645}

Get information about cached image.

cacheList (): Array
imageManager.cacheList();
// → ["http://to.some/image_1.img", "http://to.some/image_2.img", "http://to.some/image_3.img"]

List of image url's in cache.

cacheRemove (src: String): null|Object
imageManager.cacheRemove("http://to.some/image.img");
//  →  Object {element: Image, timestamp: 1430155235645}

Remove image from cache.

configGet (): Object
imageManager.configGet();
// →  {
// →      fullRepeal: false,
// →      isPaused: false,
// →      maxDownloads: 1,
// →      onError: null,
// →      onResolve: null,
// →      onSuccess: null,
// →  }

Gets the settings for downloading images.

configReset ()
imageManager.configReset();

Resets the configuration.

configSet (configName: Object|String, configValue: *)

imageManager.configSet("fullRepeal", true); // Allow cancel of image loading, applied for all new images
imageManager.configSet("maxDownloads", 99); // Maximum redowloads of image, applied for all new images
imageManager.configSet("onError", function (image) {
}); // callback for image downloading error, applied for all new images
imageManager.configSet("onResolve", function (image) {
}); // callback for image downloading finished, applied for all new images
imageManager.configSet("onSuccess", function (image) {
}); // callback for image downloading success, applied for all new images

Set configuration parameter.

imageManager.hasSource (srcUrl: String): boolean
imageManager.hasSource("http://to.some/image.img");

Is URL in the image list.

loadImage (srcUrl: String, options: Object): boolean|Number
imageManager.loadImage("http://to.some/image.img", {
	fullRepeal: boolean, // allow cancelling download request, good for big images and infinite scroll
	isPaused: boolean, // image downloadind must be started manually
	maxDownloads: number, // maximum redowloads of image, usually one is enough
	onError: Function|null, // callback on image download error
	onResolve: Function|null, // callback on image manipulations ended, called regardless of the result
	onSuccess: Function|null // allback on image download success
});

imageManager.loadImage("http://to.some/image.img", {
	onSuccess: function (image) {
		console.dir(image);
// →	{
// →		completed: true
// →		id: 25
// →		src: "http://to.some/image.img"
// →	}
	}
});

Adds an object to the image list.

onFinish: null|Fucntion
imageManager.onFinish = function () {
	console.log('Loading all images completed');
};

Callback called when everything is done.

pauseAll ()
imageManager.pauseAll();

Prevent all not started downloads.

pauseBySrc (srcUrl: String): Array|boolean|Object
imageManager.pauseBySrc("http://to.some/image.img");
imageManager.pauseBySrc(["http://to.some/image_1.img", "http://to.some/image_2.img"]);

Prevent image from being downloaded.

startAll ()
imageManager.startAll();

Start all not started downloads.

startBySrc (srcUrl: String): Array|boolean
imageManager.startBySrc("http://to.some/image.img");
// → true
// or
imageManager.startBySrc(["http://to.some/image_1.img", "http://to.some/image_2.img"]);
//  → [true, true]

Put image in download state.