(args)
| 288 | // For Server.prototype.listen(), the [...] part is [, backlog] |
| 289 | // but will not be handled here (handled in listen()) |
| 290 | function normalizeArgs(args) { |
| 291 | let arr; |
| 292 | |
| 293 | if (args.length === 0) { |
| 294 | arr = [{}, null]; |
| 295 | arr[normalizedArgsSymbol] = true; |
| 296 | return arr; |
| 297 | } |
| 298 | |
| 299 | const arg0 = args[0]; |
| 300 | let options = {}; |
| 301 | if (typeof arg0 === 'object' && arg0 !== null) { |
| 302 | // (options[...][, cb]) |
| 303 | options = arg0; |
| 304 | } else if (isPipeName(arg0)) { |
| 305 | // (path[...][, cb]) |
| 306 | options.path = arg0; |
| 307 | } else { |
| 308 | // ([port][, host][...][, cb]) |
| 309 | options.port = arg0; |
| 310 | if (args.length > 1 && typeof args[1] === 'string') { |
| 311 | options.host = args[1]; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | const cb = args[args.length - 1]; |
| 316 | if (typeof cb !== 'function') |
| 317 | arr = [options, null]; |
| 318 | else |
| 319 | arr = [options, cb]; |
| 320 | |
| 321 | arr[normalizedArgsSymbol] = true; |
| 322 | return arr; |
| 323 | } |
| 324 | |
| 325 | |
| 326 | // Called when creating new Socket, or when re-using a closed Socket |
no test coverage detected
searching dependent graphs…