Skip to content

Commit

Permalink
docs new features
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Oct 1, 2015
1 parent c409294 commit 8434a4f
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,71 @@ redolent(request)('http://www.tunnckocore.tk/').then(result => {
})
```

### redolent.promise
> Static property on which you can pass custom promise constructor.
Actually same as `Prome` argument.

**Example**

```js
const fs = require('fs')
const redolent = require('redolent')

// `q` promise will be used if not native promise available
// in node 0.10 for example
redolent.promise = require('q')
redolent(fs.readFile)('package.json', 'utf-8').then(data => {
console.log(JSON.parse(data).name)
})
```

### promisifiedFn.promise
> You also can pass custom promise module through `.promise` static property of the returned promisified function.
**Example**

```js
const fs = require('fs')
const redolent = require('redolent')

const readFile = redolent(fs.readFileSync)

// `q` promise will be used if not native promise available
// in node 0.10 for example
readFile.promise = require('q')

readFile('package.json', 'utf-8').then(data => {
console.log(JSON.parse(data).name)
})
```

### Access Promise constructor
> You can access the used Promise constructor for promisify-ing from `promise.Prome`
**Example**

```js
const fs = require('fs')
const redolent = require('redolent')

// use `pinkie` promise if not native promise available
// in node 0.10 for example
redolent.promise = require('pinkie')

const promise = redolent(fs.readFileSync)('package.json', 'utf8')

console.log(promise.Prome)
//=> will be `pinkie` promise constructor (only in node 0.10 for example)
console.log(promise.Prome.___customPromise) //=> true (only on node 0.10)
console.log(promise.___customPromise) //=> true (only on node 0.10)

promise
.then(JSON.parse)
.then(data => {
console.log(data.name) //=> `redolent`
})
```


## Related
- [always-done](https://github.com/hybridables/always-done): Handles completion and errors of anything!
Expand Down

0 comments on commit 8434a4f

Please sign in to comment.