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

all-promises

v1.5.1

Published

Collect all Promise Implementations

Downloads

9

Readme

all-promises

Build status Greenkeeper badge NPM version Dependency status

This project is try to collect all Promise implementations which follow ECMAScript 6 (which based on Promises/A+ 1.1.1).

Usage

The goal of this project is to provide a centric location to ease the comparison and testings of different implementations. Normally you only need one Promise implementation in your application, so you would mostly never use this package in the productions.

Install

npm install all-promises

API

function getPromiseConstructor(name: string): PromiseConstructor

var Promise = require('all-promises').getPromiseConstructor('q') // q implementation
var p = new Promise(function (resolve) { resolve(1) })
p.then(function (x) { assert(x === 1) })

default: PromiseConstructor

test.js file:

var Promise = require('all-promises').default // default implementation

You can specify default implementation by passing env variable:

P=rsvp node test

If no env P is provided, default to V8 native implementation

list: Array<PromiseImplementation>

interface PromiseImplementation {
	name: string,
	version: string,
	aliases: Array<string>,
	Promise: PromiseConstructor?,
	error: Error?
}
var list = require('all-promises').list

list.forEach(function (impl, index) {
	console.log(index + '.',
		'package name:', impl.name,
		'aliases:', impl.aliases,
		'version:', impl.version)
	var Promise = impl.Promise // Promise constructor
	if (Promise) Promise.resolve(1).then(function (x) { assert(x === 1) })
	else console.warn(impl.error)
})

function register(packageName: string, alias?: string|Array<string>, exportPromise?: string|function)

function unregister(name: string): boolean

function has(name: string): boolean

function get(name: string): PromiseImplementation

var promises = require('all-promises')

promises.has('es6-promise-polyfill') // false
promises.register('es6-promise-polyfill')
promises.has('es6-promise-polyfill') // true
var impl = promises.get('es6-promise-polyfill')
assert.deepEqual(impl, {
	name: 'es6-promise-polyfill',
	aliases: [],
	Promise: promises.getPromiseConstructor('es6-promise-polyfill'),
})
promises.unregister('es6-promise-polyfill') // true
promises.has('es6-promise-polyfill') // false
promises.unregister('es6-promise-polyfill') // false

Current list of implementations (order by alphabet)

| package | repo | alias | ------- | ---- | ----- | bluebird | petkaantonov/bluebird | bb | es6-promise | jakearchibald/es6-promise | | es6-promise-polyfill [^1] | lahmatiy/es6-promise-polyfill | | es6-promises | Octane/Promise | | lie | calvinmetcalf/lie | | my-promise | hax/my-promise | my | native-promise-only | getify/native-promise-only | npo | promiscuous | RubenVerborgh/promiscuous | | promise | then/promise | then | promiz | Zolmeister/promiz | | q | kriskowal/q | | rsvp | tildeio/rsvp.js | | vow | dfilatov/vow | | when | cujojs/when | w | yaku | ysmood/yaku |

[^1]: based on es6-promise, so excluded from the registery by default

How to add a new implementation

Criteria

  • MUST register on npm

  • MUST support new Promise(function executor(resolve, reject) { ... }), Promise.resolve() and Promise.reject() API

  • SHOULD pass all Promise/A+ Tests

    NOTE: Currently most implementations don't pass ES6 Promise Tests, so it's not on the MUST list up to now.

Contribute

  1. Edit implementations.js
  2. Edit package.json (npm install package-name-of-new-implementation --save)
  3. Run npm test, if everything is ok then
  4. Send pull request