diff options
Diffstat (limited to 'node_modules/socket.io-client/lib/on.js')
-rw-r--r-- | node_modules/socket.io-client/lib/on.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/node_modules/socket.io-client/lib/on.js b/node_modules/socket.io-client/lib/on.js new file mode 100644 index 0000000..fad9264 --- /dev/null +++ b/node_modules/socket.io-client/lib/on.js @@ -0,0 +1,24 @@ + +/** + * Module exports. + */ + +module.exports = on; + +/** + * Helper for subscriptions. + * + * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter` + * @param {String} event name + * @param {Function} callback + * @api public + */ + +function on (obj, ev, fn) { + obj.on(ev, fn); + return { + destroy: function () { + obj.removeListener(ev, fn); + } + }; +} |