UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

26 lines (21 loc) 629 B
/** * * @param {SignalHandler[]} handlers * @param {function} f * @param {*} [thisArg] * @returns {number} index of the handler, or -1 if not found */ export function findSignalHandlerIndexByHandle(handlers, f, thisArg) { const l = handlers.length; for (let i = 0; i < l; i++) { const signalHandler = handlers[i]; if (signalHandler.handle === f) { if (thisArg !== undefined && thisArg !== signalHandler.context) { //context variable doesn't match continue; } return i; } } return -1; }