-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kelly Huntlin
committed
Feb 11, 2025
1 parent
10650d3
commit ee7a774
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
const net = require('net'); | ||
|
||
module.exports.sleepAsync = function (ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
}; | ||
|
||
module.exports.getPortFree = function () { | ||
return new Promise(res => { | ||
const srv = net.createServer(); | ||
srv.listen(0, () => { | ||
const port = srv.address().port; | ||
srv.close(() => res(port)); | ||
}); | ||
}); | ||
}; |