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

pending

v0.1.0

Published

Abstraction for pending values

Downloads

3,245

Readme

pending

Build Status

Package defines pending value abstraction in form of three [polymorphic methods][method], where each one can be extended per type. This abstraction likely to be used in conjunction with watchable.

isPending

pending/is module provides method that must return true for all pending values and return false for all others. Method has default implementation that returns false. Types that wish to implement this abstraction should return true while value is considered pending.

var isPending = require("pending/is")

function Pending() {
  this._result = this
  this._pending = true
  this._listeners = []
}
isPending.define(Pending, function(value) {
  return value._pending
})

isPending(5)              // => false
isPending({})             // => false
isPending(new Pending)    // => true

await

pending/await module provides method that can be used to register listener that must be called once value is no longer pending. Method has default implementation that calls listener immediately with a value since non of the built-in types considered to be pending. Custom types wishing to implement this abstraction should define this method such that all registered listeners will be invoked with a delivery value once they it transitions to non-pending state.

var await = require("pending/await")
await(3, console.log)       // => info: 3
await({}, console.log)      // => info: {}

await.define(Pending, function(value, handler) {
  if (!isPending(value)) handler(value._result)
  else if (!~value._listeners.indexOf(handler)) value._listeners.push(handler)
})

deliver

pending/deliver module provides method that can is supposed to doliver pending values and transition them form pending to non-pending state, such transition supposed to happen only once. Method does not comes with default implementation as non of the built-ins are considered pending, there for attempt to call it on values that don't implement it will throw. Custom types wishing to implement pending abstraction may choose to implement it, although it's optional since some pending values may be observable but not deliverable.

var deliver = require("pending/deliver")
deliver.define(Pending, function(value, result) {
  // Ignore delivery for no longer pending values, or
  // if value delivery is already in progress.
  if (isPending(value) && value._result === value) {
    // Empty listeres array to allow registration of new listeners
    // in side effect to dispatch, in order to guarantee FIFO order.
    var count = 0
    var index = 0
    var listeners
    value._result = result
    while (index <= count) {
      if (index === count) {
        listeners = value._listeners.splice(0)
        count = listeners.length
        index = 0
        if (count === index) {
          value._pending = false
          index = index + 1
        }
      } else {
        listeners[index](result)
        index = index + 1
      }
    }
  }
})

Install

npm install pending