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

Function wrap

packages/socket.io-client/test/support/util.ts:13–27  ·  packages/socket.io-client/test/support/util.ts::wrap
(fn: (done: (err?: Error) => void) => void)

Source from the content-addressed store, hash-verified

11 * @param fn
12 */
13export function wrap(fn: (done: (err?: Error) => void) => void) {
14 let once = true;
15 return new Promise<void>((resolve, reject) => {
16 fn((err) => {
17 if (!once) {
18 throw class="st">"done() was called multiple times";
19 } else if (err) {
20 reject(err);
21 } else {
22 once = false;
23 resolve();
24 }
25 });
26 });
27}
28
29export function success(done, socket) {
30 socket.disconnect();

Callers 4

socket.tsFile · 0.90
connection.tsFile · 0.90
retry.tsFile · 0.90

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected