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]: socketio/socket.io-client@16b6569
  • Loading branch information
sunrise30 committed Oct 15, 2021
1 parent 46c618f commit dd4251d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
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 dd4251d

Please sign in to comment.