Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ fn(true).then(function (val) {
});
```

### co.setPromise(Promise)

You can custom `Promise` that you like . Such as `bluebird`, `q`, `when` and so on.

```js
var Promise = require('bluebird');
co.promise = Promise;

co(11).tap(console.log);
```

## License

MIT
Expand Down
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@

var slice = Array.prototype.slice;

/**
* default Promise
*/

var Promise = global.Promise;

/**
* Expose `co`.
*/

module.exports = co['default'] = co.co = co;

/**
* custom your Promise that you like
*/

Object.defineProperty(co,"promise",{
get: function () {
return Promise;
},
set: function (promise) {
Promise = promise;
}
});

/**
* Wrap the given generator `fn` into a
* function that returns a promise.
Expand Down