Skip to content

Commit 411673f

Browse files
committed
Merge branch 'release/v0.1.4'
2 parents 7ff2223 + 71123dc commit 411673f

File tree

5 files changed

+2534
-2693
lines changed

5 files changed

+2534
-2693
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,17 @@ async function foo(req,res) {
8181
}
8282
```
8383

84+
## Promises/A+ compliant support
85+
You never know what kind of promise you'll get from an external dependency. It can be from Bluebird, Babel polyfill or some other library. `on` should work with any promise object can `then`, such as the one provided by the popular [`bluebird`](https://github.com/petkaantonov/bluebird/) package:
86+
87+
```
88+
const {on} = require('await-on');
89+
const Bluebird = require('bluebird')
90+
91+
const fetchData = () => new Bluebird(/*...*/);
92+
const [err, data] = await on(fetchData());
93+
```
94+
95+
8496
## License
8597
MIT License. See [License](https://github.com/bitstrider/await-on/blob/master/LICENSE) in the repository.

lib/await-on.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @return {Array} Array with signature `[err, data]`
77
*/
88
function on(promise) {
9-
if(promise instanceof Promise) {
9+
if(promise && typeof promise.then === 'function') {
1010
return promise.then(data => {
1111
return [null, data];
1212
})

0 commit comments

Comments
 (0)