index.js
function off(event, fn) {
		if (typeof event !== 'string') {
			throw new Error('"event" not a string');
		}
		if (fn !== undefined && !(fn instanceof Function)) {
			throw new Error('"fn" not a Function');
		}

		if (fn) {
			// do we event have this listener
			if (!hasListener(event, fn)) {
				return false;
			}

			// unregistering a specific listener for the event
			listeners[event] = listeners[event].filter(function(l) {
				return l !== fn;
			});
			if (listeners[event].length === 0) {
				delete listeners[event];
			}
		} else {
			// do we have any listeners for this event?
			if (!hasListeners(event)) {
				return false;
			}

			// unregistering all listeners for the event
			delete listeners[event];
		}

		return true;
	}
function off(event, fn) {
		if (typeof event !== 'string') {
			throw new Error('"event" not a string');
		}
		if (fn !== undefined && !(fn instanceof Function)) {
			throw new Error('"fn" not a Function');
		}

		if (fn) {
			// do we event have this listener
			if (!hasListener(event, fn)) {
				return false;
			}

			// unregistering a specific listener for the event
			listeners[event] = listeners[event].filter(function(l) {
				return l !== fn;
			});
			if (listeners[event].length === 0) {
				delete listeners[event];
			}
		} else {
			// do we have any listeners for this event?
			if (!hasListeners(event)) {
				return false;
			}

			// unregistering all listeners for the event
			delete listeners[event];
		}

		return true;
	}
function off ( event , fn ) { if ( typeof event !== 'string' ) { throw new Error ( '"event" not a string' ) ; } if ( fn !== undefined && ! ( fn instanceof Function ) ) { throw new Error ( '"fn" not a Function' ) ; } if ( fn ) { // do we event have this listener if ( ! hasListener ( event , fn ) ) { return false ; } // unregistering a specific listener for the event listeners [ event ] = listeners [ event ] . filter ( function ( l ) { return l !== fn ; } ) ; if ( listeners [ event ] . length === 0 ) { delete listeners [ event ] ; } } else { // do we have any listeners for this event? if ( ! hasListeners ( event ) ) { return false ; } // unregistering all listeners for the event delete listeners [ event ] ; } return true ; }
Unregisters one or all listeners for an event.
@param event the event to unregister for
@param [fn] if provided, the listener function to unregister; if not
provided, all listeners will be unregistered
@return {boolean} true if listener set was modified, false if not
Unregisters one or all listeners for an event .