# promise-extensions

> extensions to make working with promises easier

Latest version **0.2.1** (published 2015-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-extensions
pnpm add promise-extensions
yarn add promise-extensions
bun add promise-extensions
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-05-24 |
| First published | 2014-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | James Brumond |
| Maintainers | k |
| Keywords | promises, promise/a+ |

## Links

- npm: https://www.npmjs.com/package/promise-extensions
- Repository: https://github.com/UmbraEngineering/promise-extensions
- Issues: https://github.com/UmbraEngineering/promise-extensions/issues
- npm.io page: https://npm.io/package/promise-extensions

## Alternatives

- [@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
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.2.1 (latest) — 2015-05-24
- 0.2.0 — 2015-05-23
- 0.1.2 — 2015-02-08
- 0.1.1 — 2015-01-23
- 0.1.0 — 2014-07-04
- 0.0.0 — 2014-07-04

## README

# Promise Extensions

Extensions to help when working with a Promises/A+ implementation.

Need promises? Maybe take a look at [promise-es6](https://github.com/UmbraEngineering/promise).



## Install

```bash
$ npm install [--save] promise-extensions
```



## Usage

```javascript
require('promise-extensions').init(Promise)
    .install('defer');

// Use the newly installed defer function
var deferred = Promise.defer();

doTheThing(function() {
    deferred.resolve('foo!');
});

deferred.promise.then(function(foo) {
    // ...
});
```



## Extensions

#### Promise.all ( Array promises )

A compliant [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) implementation. Returns a new promise that resolves once *all* of the given promises resolve.

```javascript
require('promise-extensions').init(Promise).install('all');

Promise.all([ promise1, promise2, promise3 ])
    .then(function(results) {
        //
    });
```

#### Promise.defer ( void )

Returns a deferred object containing a new promise, and a resolve and reject method.

```javascript
require('promise-extensions').init(Promise).install('defer');

var deferred = Promise.defer();

deferred.promise.then(function(foo) {
    // ...
});

deferred.resolve('foo');
```

#### Promise.guard ([ Number limit,] Function func )

Returns a new function with limited concurrency. The new function will only run a maximum of `limit` instances at a time.

```javascript
require('promise-extensions').init(Promise).install('guard');

var func = Promise.guard(3, function() {
    return new Promise(function(resolve, reject) {
        setTimeout(resolve, Math.random() * 1000);
    });
});

for (var i = 0; i < 10; i++) {
    func();
}
```

#### Promise.ify ( Function func )

Returns a new version of a node-style async function that returns a promise.

```javascript
require('promise-extensions').init(Promise).install('ify');

var nodeStyle = function(foo, bar, callback) {
    setTimeout(function() {
        callback(null, 'success!');
    }, 1000);
};

var promiseStyle = Promise.ify(nodeStyle);

promiseStyle('foo', 'bar')
    .then(function(result) {
        console.log(result);
    })
    .catch(function(err) {
        console.error(err);
    });

```

#### Promise.race ( Array promises )

<!--  -->

```javascript

```

#### Promise.wait ( Number ms )

<!--  -->

```javascript

```

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