MCPcopy Index your code
hub / github.com/socketio/socket.io / lookup

Function lookup

client-dist/socket.io.js:4399–4424  ·  view source on GitHub ↗
(uri, opts)

Source from the content-addressed store, hash-verified

4397 */
4398 var cache = {};
4399 function lookup(uri, opts) {
4400 if (_typeof(uri) === "object") {
4401 opts = uri;
4402 uri = undefined;
4403 }
4404 opts = opts || {};
4405 var parsed = url(uri, opts.path || "/socket.io");
4406 var source = parsed.source;
4407 var id = parsed.id;
4408 var path = parsed.path;
4409 var sameNamespace = cache[id] && path in cache[id]["nsps"];
4410 var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
4411 var io;
4412 if (newConnection) {
4413 io = new Manager(source, opts);
4414 } else {
4415 if (!cache[id]) {
4416 cache[id] = new Manager(source, opts);
4417 }
4418 io = cache[id];
4419 }
4420 if (parsed.query && !opts.query) {
4421 opts.query = parsed.queryKey;
4422 }
4423 return io.socket(parsed.path, opts);
4424 }
4425 // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a
4426 // namespace (e.g. `io.connect(...)`), for backward compatibility
4427 _extends(lookup, {

Callers

nothing calls this directly

Calls 3

_typeofFunction · 0.85
urlFunction · 0.85
socketMethod · 0.80

Tested by

no test coverage detected