MCPcopy Index your code
hub / github.com/developit/mitt / off

Function off

src/index.ts:82–91  ·  view source on GitHub ↗

* Remove an event handler for the given type. * If `handler` is omitted, all handlers of the given type are removed. * @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler) * @param {Function} [handler] Handler function to remove * @m

(type: Key, handler?: GenericEventHandler)

Source from the content-addressed store, hash-verified

80 * @memberOf mitt
81 */
82 off<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {
83 const handlers: Array<GenericEventHandler> | undefined = all!.get(type);
84 if (handlers) {
85 if (handler) {
86 handlers.splice(handlers.indexOf(handler) >>> 0, 1);
87 } else {
88 all!.set(type, []);
89 }
90 }
91 },
92
93 /**
94 * Invoke all handlers for the given type.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected