# all-promises

> Collect all Promise Implementations

Latest version **1.5.1** (published 2017-07-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install all-promises
pnpm add all-promises
yarn add all-promises
bun add all-promises
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2017-07-20 |
| First published | 2015-02-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | HE Shi-Jun |
| Maintainers | hax |
| Keywords | promises, promises-aplus |

## Links

- npm: https://www.npmjs.com/package/all-promises
- Repository: https://github.com/hax/all-promises
- Issues: https://github.com/hax/all-promises/issues
- npm.io page: https://npm.io/package/all-promises

## Dependencies (15)

- [q](https://npm.io/package/q.md) ~1.5.0
- [lie](https://npm.io/package/lie.md) ~3.1.0
- [vow](https://npm.io/package/vow.md) ~0.4.12
- [rsvp](https://npm.io/package/rsvp.md) ~3.6.0
- [when](https://npm.io/package/when.md) ~3.7.7
- [yaku](https://npm.io/package/yaku.md) ~0.18.0
- [promiz](https://npm.io/package/promiz.md) ~1.0.5
- [promise](https://npm.io/package/promise.md) ~8.0.1
- [bluebird](https://npm.io/package/bluebird.md) ~3.5.0
- [my-promise](https://npm.io/package/my-promise.md) ~1.1.0
- [es6-promise](https://npm.io/package/es6-promise.md) ~4.1.0
- [promiscuous](https://npm.io/package/promiscuous.md) ~0.7.0
- [es6-promises](https://npm.io/package/es6-promises.md) ~1.0.10
- [native-promise-only](https://npm.io/package/native-promise-only.md) ~0.8.1
- [es6-promise-polyfill](https://npm.io/package/es6-promise-polyfill.md) ~1.2.0

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.5.1 (latest) — 2017-07-20
- 1.5.0 — 2017-03-23
- 1.4.0 — 2016-10-27
- 1.3.0 — 2016-04-25
- 1.2.0 — 2015-03-18
- 1.1.0 — 2015-03-18
- 1.0.0 — 2015-02-02

## README

# all-promises

[![Build status][travis-image]][travis-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[![NPM version][npm-image]][npm-url]
[![Dependency status][david-image]][david-url]

This project is try to collect all Promise implementations which follow [ECMAScript 6](http://www.ecma-international.org/ecma-262/6.0/) (which based on [Promises/A+ 1.1.1](https://promisesaplus.com/)).


## 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.

<!--To find which Promise implementation you should adopt, or just want a solid Promise implementation, I suggest my-promise.-->


### Install

```sh
npm install all-promises
```


### API


#### `function getPromiseConstructor(name: string): PromiseConstructor`

```js
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:
```js
var Promise = require('all-promises').default // default implementation
```

You can specify default implementation by passing env variable:
```sh
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?
}
```

```js
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`

```js
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](https://www.npmjs.com/package/bluebird) | [petkaantonov/bluebird](https://github.com/petkaantonov/bluebird) | bb
| [es6-promise](https://www.npmjs.com/package/es6-promise) | [jakearchibald/es6-promise](https://github.com/jakearchibald/es6-promise) |
| [es6-promise-polyfill](https://www.npmjs.com/package/es6-promise-polyfill) [^1] | [lahmatiy/es6-promise-polyfill](https://github.com/lahmatiy/es6-promise-polyfill) |
| [es6-promises](https://www.npmjs.com/package/es6-promises) | [Octane/Promise](https://github.com/Octane/Promise) |
| [lie](https://www.npmjs.com/package/lie) | [calvinmetcalf/lie](https://github.com/calvinmetcalf/lie) |
| [my-promise](https://www.npmjs.com/package/my-promise) | [hax/my-promise](https://github.com/hax/my-promise) | my
| [native-promise-only](https://www.npmjs.com/package/native-promise-only) | [getify/native-promise-only](https://github.com/getify/native-promise-only) | npo
| [promiscuous](https://www.npmjs.com/package/promiscuous) | [RubenVerborgh/promiscuous](https://github.com/RubenVerborgh/promiscuous) |
| [promise](https://www.npmjs.com/package/promise) | [then/promise](https://github.com/then/promise) | then
| [promiz](https://www.npmjs.com/package/promiz) | [Zolmeister/promiz](https://github.com/Zolmeister/promiz) |
| [q](https://www.npmjs.com/package/q) | [kriskowal/q](https://github.com/kriskowal/q) |
| [rsvp](https://www.npmjs.com/package/rsvp) | [tildeio/rsvp.js](https://github.com/tildeio/rsvp.js) |
| [vow](https://www.npmjs.com/package/vow) | [dfilatov/vow](https://github.com/dfilatov/vow) |
| [when](https://www.npmjs.com/package/when) | [cujojs/when](https://github.com/cujojs/when) | w
| [yaku](https://www.npmjs.com/package/yaku) | [ysmood/yaku](https://github.com/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](https://github.com/promises-aplus/promises-tests)

	NOTE: Currently most implementations don't pass [ES6 Promise Tests](https://github.com/promises-es6/promises-es6), so it's not on the MUST list up to now.


### Contribute

 0. Edit [implementations.js](https://github.com/hax/all-promises/blob/master/implementations.js)
 0. Edit [package.json](https://github.com/hax/all-promises/blob/master/package.json) (`npm install package-name-of-new-implementation --save`)
 0. Run `npm test`, if everything is ok then
 0. Send [pull request](https://github.com/hax/all-promises/pulls)


[travis-image]: https://img.shields.io/travis/hax/all-promises.svg
[travis-url]: https://travis-ci.org/hax/all-promises
[greenkeeper-image]: https://badges.greenkeeper.io/hax/all-promises.svg
[greenkeeper-url]: https://greenkeeper.io/
[npm-image]: https://img.shields.io/npm/v/all-promises.svg
[npm-url]: https://npmjs.org/package/all-promises
[david-image]: https://img.shields.io/david/hax/all-promises.svg
[david-url]: https://david-dm.org/hax/all-promises

---
_Source: https://npm.io/package/all-promises · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
