MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / getFreePort

Function getFreePort

tooling/scripts/sidebar-vim-smoke.mjs:95–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93}
94
95function getFreePort() {
96 return new Promise((res, rej) => {
97 const s = net.createServer()
98 s.listen(0, '127.0.0.1', () => { const a = s.address(); s.close(() => res(a.port)) })
99 s.on('error', rej)
100 })
101}
102function httpGetJson(url) {
103 return new Promise((res, rej) => {
104 const req = http.get(url, (r) => { let b = ''; r.on('data', (c) => (b += c)); r.on('end', () => { try { res(JSON.parse(b)) } catch (e) { rej(e) } }) })

Callers 1

mainFunction · 0.70

Calls 2

closeMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected