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

chain-promise-data

v0.1.1

Published

The purpose of this utility is to chain data from a chain of promises, into one custom object that looks the way you want it.

Readme

Chain Promise Data

The purpose of this utility is to chain data from a chain of promises, into one custom object that looks the way you want it.

The problem

When chaining promises you often want to use the resulting data from one promise in another function further down the chain.

This means you either have to pass that piece of data to several functions that do nothing with it but return it so it can be consumed later in the chain (or you have to assign it to a variable i the scope outside of your promise chain).

A solution

Promise Data Chain wraps your promise functions that preserves the data object from the previous step, merges in the result from the current step and passed the merged object to the next step.

Usage

chainData(promiseFn, mapperFn)

The first argument is a function that returns a promise, and the second argument is a mapper function which takes the result of the promise and returns a new object after doing whatever it wants to the result data.

Mapper functions are great for renaming props, or processing/formatting the data before it gets added to the chained object.

Alternatively, if you just want to cherry-pick a few properties off of a bigger object you can supply an array of keys in place of the mapper function.

Hopefully the example usage makes things a little more clear:

Example

import chainData from 'chain-promise-data';
chainData(
  () => getPost(123), // returns { id: 123, body: 'Hello, world!', authorId: 321 }
  ({ id, body, authorId }) => ({ postId: id, authorId, body }) // Mapper function that can cherry-pick and rename props
)
  .then(
    chainData(
      ({ authorId }) => getUser(authorId), // returns { id: 321, fullName: 'Don Quijote', hobbies: 'Windmilling' }
      ['fullName'] // Pick out only the full name prop and add it to your data object
    )
  )
  .then(
    ({ postId }) => getComments(postId), // Returns [{ id: 12345, body: 'Hiiii!' }, {id: 12346: 'Yo' }],
    comments => ({ comments }) // Add response data as `comments` to your data object
  )
  .then(result => {
    // Do something with your result object here that now has the shape:
    {
      postId: 123,
      authorId: 321,
      body: 'Hello, world!',
      fullName: 'Don Quijote',
      comments: [
        { id: 12345, body: 'Hiiii!' },
        {id: 12346: 'Yo' }
      ]
    }
  })