Skip to content

Commit

Permalink
fix: restore the namespace export
Browse files Browse the repository at this point in the history
This restores the previous behavior, where the "io" object available in
the browser could be used as a function (`io()`) or as a namespace
(`io.connect()`).

The breaking change was introduced in [1].

Related: socketio/socket.io#4121

[1]: 16b6569
  • Loading branch information
chriskrycho authored and darrachequesne committed Oct 15, 2021
1 parent c76d367 commit 8737d0a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/index.ts
Expand Up @@ -71,6 +71,15 @@ function lookup(
return io.socket(parsed.path, opts);
}

// so that "lookup" can be used both as a function (e.g. `io(...)`) and as a
// namespace (e.g. `io.connect(...)`), for backward compatibility
Object.assign(lookup, {
Manager,
Socket,
io: lookup,
connect: lookup,
});

/**
* Protocol version.
*
Expand Down

0 comments on commit 8737d0a

Please sign in to comment.