MCPcopy
hub / github.com/socketio/socket.io / run

Method run

packages/socket.io/lib/socket.ts:871–890  ·  view source on GitHub ↗

* Executes the middleware for an incoming event. * * @param {Array} event - event that will get emitted * @param {Function} fn - last fn call in the middleware * @private

(event: Event, fn: (err?: Error) => void)

Source from the content-addressed store, hash-verified

869 * @private
870 */
871 private run(event: Event, fn: (err?: Error) => void): void {
872 if (!this.fns.length) return fn();
873
874 const fns = this.fns.slice(0);
875
876 function run(i: number) {
877 fns[i](event, (err) => {
878 // upon error, short-circuit
879 if (err) return fn(err);
880
881 // if no middleware left, summon callback
882 if (!fns[i + 1]) return fn();
883
884 // go on to next
885 run(i + 1);
886 });
887 }
888
889 run(0);
890 }
891
892 /**
893 * Whether the socket is currently disconnected

Callers 1

dispatchMethod · 0.95

Calls 2

fnFunction · 0.85
runFunction · 0.85

Tested by

no test coverage detected