Skip to content

Commit 01ac9a3

Browse files
committed
Version 1.3.0
1 parent e9ede6c commit 01ac9a3

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@
22

33
[![Build Status](https://secure.travis-ci.org/kevinbeaty/any-promise.svg)](http://travis-ci.org/kevinbeaty/any-promise)
44

5-
Let your library support any ES 2015 (ES6) compatible `Promise` and leave the choice to application authors. The application can register its preferred `Promise` implementation and it will be exported when requiring `any-promise` from library code.
5+
Let your library support any ES 2015 (ES6) compatible `Promise` and leave the choice to application authors. The application can *optionally* register its preferred `Promise` implementation and it will be exported when requiring `any-promise` from library code.
66

77
If no preference is registered, defaults to the global `Promise` for newer Node.js versions. The browser version defaults to the window `Promise`, so polyfill or register as necessary.
88

9-
#### Usage:
9+
### Usage with global Promise:
10+
11+
Assuming the global `Promise` is the desired implementation:
12+
13+
```bash
14+
# Install any libraries depending on any-promise
15+
$ npm install mz
16+
```
17+
18+
The installed libraries will use global Promise by default.
19+
20+
```js
21+
// in library
22+
var Promise = require('any-promise') // the global Promise
23+
24+
function promiseReturningFunction(){
25+
return new Promise(function(resolve, reject){...})
26+
}
27+
```
28+
29+
### Usage with registration:
1030

1131
Assuming `bluebird` is the desired Promise implementation:
1232

@@ -18,6 +38,7 @@ $ npm install any-promise
1838
# Install any libraries you would like to use depending on any-promise
1939
$ npm install mz
2040
```
41+
2142
Register your preference in the application entry point before any other `require` of packages that load `any-promise`:
2243

2344
```javascript
@@ -38,7 +59,7 @@ var Promise = require('any-promise') // the registered bluebird promise
3859

3960
It is safe to call `register` multiple times, but it must always be with the same implementation.
4061

41-
Again, registration is *optional*. It should only be called by the application user if overriding the global `Promise` implemementation is desired.
62+
Again, registration is *optional*. It should only be called by the application user if overriding the global `Promise` implementation is desired.
4263

4364
### Optional Application Registration
4465

@@ -118,7 +139,7 @@ return new Promise(function(resolve, reject){
118139

119140
```
120141

121-
Libraries using `any-promise` should only use [documented](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) functions as there is no guarantee which implementation will be chosen by the application author. Libraries should never call `register`, only the application user should call if desired.
142+
Except noted below, libraries using `any-promise` should only use [documented](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) functions as there is no guarantee which implementation will be chosen by the application author. Libraries should never call `register`, only the application user should call if desired.
122143

123144

124145
#### Advanced Library Usage

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "any-promise",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Resolve any installed ES6 compatible promise",
55
"main": "index.js",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)