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

indigobird

v1.0.0

Published

A complement to bluebird which is also probably slightly better.

Downloads

82

Readme

GitHub license npm version PRs Welcome

What is indigobird?

Much of the same functionality as bluebird, except everything allows for concurrency and handlers, as well as additional functionality, such as asynchronous .reduce.

Install

Node Install:

$ npm install --save indigobird

Deno Install:

// Coming soon

Where it's like bluebird:

import indigobird from 'indigobird';

// Like Promise.all or bluebird's variant
indigobird.all([
  doSomethingAsync(),
  doSomethingAsync(),
  doSomethingAsync(),
]);

// Like bluebird's .some, we wait for `amount` to resolve
// successfully before resolving the batch.
indigobird.some([
  doSomethingAsync(),
  doSomethingAsync(),
  doSomethingAsync(),
], { amount: 2 });

// Like bluebird's .props, we resolve the promises at the keys'
// values, and map them onto a result object with the same keys
indigobird.props({
  head: getHeadAsync(),
  shoulders: getShouldersAsync(),
  knees: getKneesAsync(),
  toes: getToesAsync(),
});

// Like .some, but has `amount` set to 1.
indigibird.any([
  doSomethingAsync(),
  doSomethingAsync(),
  doSomethingAsync(),
]);

Where it's NOT like bluebird

Rather than just handing an array of promises, like Promise.all or bluebird's .some, all of these utilities can also be passed a handler argument

// This then behaves like bluebird's .map, where
// arguments in an array will be passed into an asynchronous handler,
// and can therefore have their concurrency specified in the `concurrency`
// argument.
indigobird.some(userIds, (userId) => {
  return validateAndFetchUser(userId);
}, { amount: 5, concurrency: 3});

Rather than invoking the functions at a given prop, we could, for example, just pass them instead. Then we could invoke them in the handler, and benefit from having control over concurrency.

indigobird.props({
  head: getHeadAsync,
  shoulders: getShouldersAsync,
  knees: getKneesAsync,
  toes: getToesAsync,
}, fn => fn(), { concurrency: 3 });

There is also unique functionality typically unavailable to asynchronous libraries, such as .reduce.

const arr = [1, 2, 3, 6, 4, 2, 9, 1, 64];
const sum = await reduce(arr, async (getAggregate, n) => {
  // Notice that because these handlers are meant to be executed
  // asynchronously, rather than passing in `sum`, or the equivalent
  // aggregate value, which would have issues with having the closure
  // capture an aggregate value which may have become stale during
  // concurrent execution of peer handlers, we instead provide a getter.
  // This way, when ready to use the aggregate, the getter can be invoked
  // for access to the aggregate value that is in up to date.
  const someValue = await someAsynchronousThing(n);
  return getAggregate() + someValue;
}, 0, { concurrency: 6 });