Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Aug 24, 2016
1 parent 4b09671 commit 2bd5e54
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@ const getPromise = require('native-or-another')
```

### [nativeOrAnother](./index.js#L44)
> Always will expose native `Promise` if available. Otherwise given promise module or Bluebird.
> Always will expose native `Promise` if available. Otherwise given promise module or Bluebird if installed, otherwise throws with message.
- `[Prome]` **{Function}** custom promise module
- `returns` **{Function}** native Promise or another
- `[Promize]` **{Function}** custom promise module
- `returns` **{Function}** native Promise or another
- `throws` **{Error}** possible when
1. no native Promise support and
2. no `Promize` implementation (constructor) were given and
3. no `bluebird` not installed (as devDependency is enough)

**Example**

```js
const fs = require('fs')
const NativeOrBluebird = getPromise()
// => `bluebird` promise, but only if installed,
// throws otherwise

const NativeOrPromise = getPromise(require('promise'))
const NativeOrPinkie = getPromise(require('pinkie'))
const NativeOrQ = getPromise(require('q'))
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var NativePromise = require('native-promise')

/**
* Always will expose native `Promise` if available.
* Otherwise given promise module or Bluebird.
* Otherwise given promise module or Bluebird if installed,
* otherwise throws with message.
*
* **Example**
*
Expand Down Expand Up @@ -42,6 +43,11 @@ var NativePromise = require('native-promise')
* @name nativeOrAnother
* @param {Function} `[Promize]` custom promise module
* @return {Function} native Promise or another
* @throws {Error} If
* 1. no native Promise support AND
* 2. no `Promize` implementation (constructor) were given AND
* 3. no `bluebird` were not found/installed (as devDependency is enough)
*
* @api public
*/
module.exports = function nativeOrAnother (Promize) {
Expand Down

0 comments on commit 2bd5e54

Please sign in to comment.