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

promiset

v0.8.4

Published

A minimal and fast promise implementation

Readme

promiset

promiset is a tiny implementation of the Promises/A+ spec.

It is promise library in JavaScript, small (< 1kb minified / < 0.6kb gzipped) and fast.

Installation and usage

Node

First, install promiset with npm.

$ npm install promiset

Then, include promiset in your code file.

var Promise = require('promiset');

Browsers

Include promiset in your HTML file.

<script src="promiset-browser.js"></script>

This version (and a minified one) can be built with:

$ build/build.js

API

Create a resolved promise

var promise = Promise.resolve("one");
promise.then(function (value) { console.log(value); });
/* one */

Create a rejected promise

var brokenPromise = Promise.reject(new Error("Could not keep promise."));
brokenPromise.then(null, function (error) { console.error(error.message); });
/* "Could not keep promise." */

You can also use the catch method if there is no success callback:

brokenPromise.catch(function (error) { console.error(error.message); });
/* "Could not keep promise." */

Write a function that returns a promise

function promiseLater(something) {
  return new Promise(function (resolve, reject) {
    setTimeout(function () {
      if (something)
        resolve(something);
      else
        reject(new Error("nothing"));
    }, 1000);
  });
}
promiseLater("something").then(
  function (value) { console.log(value); },
  function (error) { console.error(error.message); });
/* something */

promiseLater(null).then(
  function (value) { console.log(value); },
  function (error) { console.error(error.message); });
/* nothing */

.spread fulfillment value

Like calling .then, but the fulfillment value could be an array, which is flattened to the formal parameters of the fulfillment handler.

Promise.resolve([1,2]).spread((a, b) => console.log(a, b))
/* 1 2 */
Promise.resolve(1).spread(a => console.log(a))
/* 1 */

Convert an array of promises into a promise for an array

var promises = [promiseLater(1), promiseLater(2), promiseLater(3)];
Promise.all(promises).then(function (values) { console.log(values); });
/* [1, 2, 3] */

Execute an array of promises, returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects, with the value or reason from that promise.

var promises = [promiseLater(1), promiseLater(2), promiseLater(3)];
Promise.race(promises).then(function (values) { console.log(values); });
/* 1 */

Execute an array of tasks which return a promise serially, returns a promise with array contain the value of every resolved promise in the task function, but it will reject if any of the promises is rejected.

var task1 = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log('task1');
      resolve('task1');
    }, 2000);
  })
}

var task2 = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log('task2');
      resolve('task2');
    }, 2000);
  })
}

var task3 = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log('task3');
      resolve('task3');
    }, 3000);
  })
}

Promise.serial([task1, task2, task3])
  .then(data => {
    console.log('data:', data);
  })
  .catch(err => {
    console.log('err', err);
  })

var promises = [task1, task2, task3];
Promise.serial(promises).then(function (values) { console.log(values); });
/* task1
   task2
   task3
   data: ["task1", "task2", "task3"] */