| [9af201e] | 1 |
|
|---|
| 2 | # thenify-all
|
|---|
| 3 |
|
|---|
| 4 | [![NPM version][npm-image]][npm-url]
|
|---|
| 5 | [![Build status][travis-image]][travis-url]
|
|---|
| 6 | [![Test coverage][coveralls-image]][coveralls-url]
|
|---|
| 7 | [![Dependency Status][david-image]][david-url]
|
|---|
| 8 | [![License][license-image]][license-url]
|
|---|
| 9 | [![Downloads][downloads-image]][downloads-url]
|
|---|
| 10 | [![Gittip][gittip-image]][gittip-url]
|
|---|
| 11 |
|
|---|
| 12 | Promisifies all the selected functions in an object.
|
|---|
| 13 |
|
|---|
| 14 | ```js
|
|---|
| 15 | var thenifyAll = require('thenify-all');
|
|---|
| 16 |
|
|---|
| 17 | var fs = thenifyAll(require('fs'), {}, [
|
|---|
| 18 | 'readFile',
|
|---|
| 19 | 'writeFile',
|
|---|
| 20 | ]);
|
|---|
| 21 |
|
|---|
| 22 | fs.readFile(__filename).then(function (buffer) {
|
|---|
| 23 | console.log(buffer.toString());
|
|---|
| 24 | });
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 | ## API
|
|---|
| 28 |
|
|---|
| 29 | ### var obj = thenifyAll(source, [obj], [methods])
|
|---|
| 30 |
|
|---|
| 31 | Promisifies all the selected functions in an object.
|
|---|
| 32 |
|
|---|
| 33 | - `source` - the source object for the async functions
|
|---|
| 34 | - `obj` - the destination to set all the promisified methods
|
|---|
| 35 | - `methods` - an array of method names of `source`
|
|---|
| 36 |
|
|---|
| 37 | ### var obj = thenifyAll.withCallback(source, [obj], [methods])
|
|---|
| 38 |
|
|---|
| 39 | Promisifies all the selected functions in an object and backward compatible with callback.
|
|---|
| 40 |
|
|---|
| 41 | - `source` - the source object for the async functions
|
|---|
| 42 | - `obj` - the destination to set all the promisified methods
|
|---|
| 43 | - `methods` - an array of method names of `source`
|
|---|
| 44 |
|
|---|
| 45 | ### thenifyAll.thenify
|
|---|
| 46 |
|
|---|
| 47 | Exports [thenify](https://github.com/thenables/thenify) this package uses.
|
|---|
| 48 |
|
|---|
| 49 | [gitter-image]: https://badges.gitter.im/thenables/thenify-all.png
|
|---|
| 50 | [gitter-url]: https://gitter.im/thenables/thenify-all
|
|---|
| 51 | [npm-image]: https://img.shields.io/npm/v/thenify-all.svg?style=flat-square
|
|---|
| 52 | [npm-url]: https://npmjs.org/package/thenify-all
|
|---|
| 53 | [github-tag]: http://img.shields.io/github/tag/thenables/thenify-all.svg?style=flat-square
|
|---|
| 54 | [github-url]: https://github.com/thenables/thenify-all/tags
|
|---|
| 55 | [travis-image]: https://img.shields.io/travis/thenables/thenify-all.svg?style=flat-square
|
|---|
| 56 | [travis-url]: https://travis-ci.org/thenables/thenify-all
|
|---|
| 57 | [coveralls-image]: https://img.shields.io/coveralls/thenables/thenify-all.svg?style=flat-square
|
|---|
| 58 | [coveralls-url]: https://coveralls.io/r/thenables/thenify-all
|
|---|
| 59 | [david-image]: http://img.shields.io/david/thenables/thenify-all.svg?style=flat-square
|
|---|
| 60 | [david-url]: https://david-dm.org/thenables/thenify-all
|
|---|
| 61 | [license-image]: http://img.shields.io/npm/l/thenify-all.svg?style=flat-square
|
|---|
| 62 | [license-url]: LICENSE
|
|---|
| 63 | [downloads-image]: http://img.shields.io/npm/dm/thenify-all.svg?style=flat-square
|
|---|
| 64 | [downloads-url]: https://npmjs.org/package/thenify-all
|
|---|
| 65 | [gittip-image]: https://img.shields.io/gratipay/jonathanong.svg?style=flat-square
|
|---|
| 66 | [gittip-url]: https://gratipay.com/jonathanong/
|
|---|