added EventEmitter.once compatibility

This commit is contained in:
brianc 2010-10-23 12:45:37 -05:00
parent f9f7e0759d
commit d45c905978
2 changed files with 12 additions and 1 deletions

View File

@ -3,7 +3,7 @@ var net = require('net');
var Query = require(__dirname+'/query');
var sys = require('sys');
var crypto = require('crypto');
var utils = require(__dirname + '/utils');
var Client = function(config) {
EventEmitter.call(this);
config = config || {};

11
lib/utils.js Normal file
View File

@ -0,0 +1,11 @@
var events = require('events');
if(typeof events.EventEmitter.prototype.once !== 'function') {
events.EventEmitter.prototype.once = function (type, listener) {
var self = this;
self.on(type, function g () {
self.removeListener(type, g);
listener.apply(this, arguments);
});
};
}