Skip to content

Commit

Permalink
Add async methods.
Browse files Browse the repository at this point in the history
Now you can use
- Client.prototype.writeAsync
- Client.prototype.kickAsync
- Client.prototype.modeAsync
- etc...

They take the same arguments as the original methods except callback. And they
return a promise.
  • Loading branch information
sgkim126 committed Apr 25, 2016
1 parent bdc16c4 commit f863eff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var Emitter = require('events').EventEmitter;
var debug = require('debug')('qbirc');
var Parser = require('qbirc-parser');
var replies = require('irc-replies');
var Promise = require('bluebird');

/**
* Core plugins.
Expand Down Expand Up @@ -411,3 +412,10 @@ Client.prototype.onmessage = function(msg) {
function toArray(val) {
return Array.isArray(val) ? val : [val];
}


/**
* Add async methods that return a promise.
*/

Promise.promisifyAll(Client.prototype);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"chat"
],
"dependencies": {
"bluebird": "^3.3.5",
"debug": "^2.2.0",
"irc-replies": "^2.0.1",
"qbirc-parser": "^0.1.1",
"debug": "^2.2.0"
"qbirc-parser": "^0.1.1"
},
"devDependencies": {
"mocha": "^2.4.5",
Expand Down

0 comments on commit f863eff

Please sign in to comment.