租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.5 KiB

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