TEXT 291
On.js Guest on 17th April 2021 09:56:06 AM
  1.  
  2. /**
  3.  * Module exports.
  4.  */
  5.  
  6. module.exports = on;
  7.  
  8. /**
  9.  * Helper for subscriptions.
  10.  *
  11.  * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`
  12.  * @param {String} event name
  13.  * @param {Function} callback
  14.  * @api public
  15.  */
  16.  
  17. function on (obj, ev, fn) {
  18.   obj.on(ev, fn);
  19.   return {
  20.     destroy: function () {
  21.       obj.removeListener(ev, fn);
  22.     }
  23.   };
  24. }

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.