blob: 323e645a5ce3f07b474e87c0b93148f08f4d4af5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# defer-to-connect
> The safe way to handle the `connect` socket event
Once you receive the socket, it may be already connected.<br>
To avoid checking that, use `defer-to-connect`. It'll do that for you.
## Usage
```js
const deferToConnect = require('defer-to-connect');
deferToConnect(socket, () => {
console.log('Connected!');
});
```
## API
### deferToConnect(socket, fn)
Calls `fn()` when connected.
## License
MIT
|