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

bluebird-extra

v2.0.0

Published

Extra methods for bluebird promises library

Downloads

318

Readme

bluebird-extra

Extra methods for bluebird promises library

Current status

NPM version Build Status Dependency Status Dev dependency Status Coverage Status

API is stable. Test coverage of all features.

Suggestions on additional methods to add or ways to improve the existing methods are very welcome.

Usage

Augments bluebird with extra flow control methods, similar to what's available in async (for async code) or lodash (for sync code).

Loading module

To load module:

var Promise = require('bluebird-extra');

This returns an independent instance of bluebird v2, augmented with additional methods. It does not alter the global version of bluebird which would be received from require('bluebird').

Or, to use another version of bluebird as the base for augmentation:

var Promise = require('bluebird');
require('bluebird-extra').usePromise(Promise);

Additional methods

All the following methods can be called either on the Promise constructor, or a Promise instance.

e.g.

Promise.mapSeries([1, 2], function(value) {
	// do something
});

Promise.resolve([1, 2]).mapSeries(function(value) {
	// do something
});

eachParallel()

Like Promise.each() but run in parallel.

mapSeries()

Like Promise.map() but run in series.

mapOwn()

Aliases: mapObject(), mapValues()

Maps an object like lodash.mapValues()

Promise.mapOwn({ a: 1, b: 2 }, function(value, key, object) {
	// do something to the value and return it
});

mapIn()

Same as mapOwn() but also iterates through properties inherited from prototype.

mapOwnSeries()

Aliases: mapObjectSeries(), mapValuesSeries()

Same as mapOwn() but run in series.

mapInSeries()

Same as mapIn() but run in series.

own()

Iterates through properties of an object, calling the iterator function on each. Returns the object unchanged.

Promise.own({ a: 1, b: 2 }, function(value, key, object) {
	// do something
});

ownSeries()

Alias: forOwn()

Same as own() but run in series.

in()

Same as own() but also iterates through properties inherited from prototype.

inSeries()

Alias: forIn()

Same as in() but run in series.

eachAny()

Runs iterator on each item in an array in series until the iterator returns a result that is not undefined. Iteration is stopped and this result is returned.

ifElse()

Tests the value passed in. If truthy, the if function is run, otherwise the else function is run.

Promise.ifElse(testExpression, function(value) {
	// this runs if testExpression is truthy
}, function(value) {
	// this runs if testExpression is not truthy
});

each()

Aliases: forEach(), eachSeries()

Promise.each() is a native bluebird construct. forEach() and eachSeries() are aliases for it, included for consistency.

Tests

Use npm test to run the tests. Use npm run cover to check coverage.

Changelog

See changelog.md

Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/bluebird-extra/issues

Contribution

Pull requests are very welcome. Please:

  • ensure all tests pass before submitting PR
  • add an entry to changelog
  • add tests for new features
  • document new functionality/API additions in README