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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-promise-visualizer

v0.0.5

Published

react component showing visual notification for asynchronized works

Readme

react-promise-visualizer

A React component showing visual notification for your asynchronized works.

Synopsis

render() {
  return <Visualizer provider={new DefaultProvider} ref={c => this.v = c} />;
}

sendAJAX() {
  this.v.show($.ajax({url: "..."})).then(data => console.log(data));
}

See example/ for more detailed usage (in typescript). There's also a live demo.

How it works

Visualizer is just a span with only one child node, which represents the state of promise.

By passing a Promise object to show() method, Visualizer will inject the component whichi indicates "a promise is running", and set the span's opacity to 1.

After promise is resolved/rejected, the component is replaced by the new one which represents new state, and container's opacity is setted to 0 after a short period.

show() will wrap you promise in a new promise object and returns it. The new one logically equals to old one, it does not represents the life cycle or event of visualizer.

It should be safe to call show() multiple times: old one will keep running, your .then() will be executed correctly, and only newest one can change the state of visualizer. This is done by allocating a numeric identifier for each promise object internally.

Available properties

Visualizer accepts three properties:

  • className: The css class of the container. The container will be a span. optional
  • provider: See next section. required
  • duration: How many milliseconds should visualizer keep showing after resolved/rejected. optional, defaults to 3000

Provider

A provider returns react components representing state of promise. The default implementation uses svg images and css animation. You can easily write your own in seconds: it's nothing but an object with three function: done(), failed() nd running(), each represents a different state.

var myProvider = {
  done() { return <img src="images/ok.png" />; }
  failed() { return <img src="images/error.png" />; }
  running() { return <img src="images/spin.gif" />; }
};

render() {
  return <Visualizer provider={myProvider} ref={c => this.v = c} />;
}

Default provider

Since default provider is implemented using svg images, you MUST specify the width and height of the container(span). Specifying className is strongly recommended.

You can open live demo above, remove width/height using browser's developer tool, and see what happends.

License

MIT and GPLv3, you must choose one explicitly, or it will default to GPLv3.

The css in default provider is copied and modified from fontello. See fontello-license.txt for more license information.