用工小程序前端代码
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.

70 lines
1.7 KiB

6 months ago
  1. sdk-base
  2. ---------------
  3. [![NPM version][npm-image]][npm-url]
  4. [![build status][travis-image]][travis-url]
  5. [![Test coverage][coveralls-image]][coveralls-url]
  6. [![Gittip][gittip-image]][gittip-url]
  7. [![David deps][david-image]][david-url]
  8. [![npm download][download-image]][download-url]
  9. [npm-image]: https://img.shields.io/npm/v/sdk-base.svg?style=flat-square
  10. [npm-url]: https://npmjs.org/package/sdk-base
  11. [travis-image]: https://img.shields.io/travis/node-modules/sdk-base.svg?style=flat-square
  12. [travis-url]: https://travis-ci.org/node-modules/sdk-base
  13. [coveralls-image]: https://img.shields.io/coveralls/node-modules/sdk-base.svg?style=flat-square
  14. [coveralls-url]: https://coveralls.io/r/node-modules/sdk-base?branch=master
  15. [gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
  16. [gittip-url]: https://www.gittip.com/dead-horse/
  17. [david-image]: https://img.shields.io/david/node-modules/sdk-base.svg?style=flat-square
  18. [david-url]: https://david-dm.org/node-modules/sdk-base
  19. [download-image]: https://img.shields.io/npm/dm/sdk-base.svg?style=flat-square
  20. [download-url]: https://npmjs.org/package/sdk-base
  21. A base class for sdk with default error handler.
  22. ## Installation
  23. ```bash
  24. $ npm install sdk-base
  25. ```
  26. ## Usage
  27. ```js
  28. var Base = require('sdk-base');
  29. var util = require('util');
  30. function Client() {
  31. Base.call(this);
  32. }
  33. util.inherits(Client, Base);
  34. ```
  35. ### API
  36. - `.ready(flagOrFunction)`
  37. ```js
  38. // init ready
  39. client.ready(true);
  40. // listen client ready
  41. client.ready(function() {
  42. console.log('client is ready');
  43. });
  44. ```
  45. - `.on(event, listener)`
  46. ```js
  47. // listen error event
  48. client.on('error', function(err) {
  49. console.error(err.stack);
  50. });
  51. ```
  52. ### License
  53. MIT