Created
September 19, 2018 17:11
-
-
Save styks1987/e29f719c542f2ee9536f3c3bdaad7688 to your computer and use it in GitHub Desktop.
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
const net = require('net'); | |
export default () => { | |
return new Promise(resolve => { | |
const server = net.createServer(); | |
server.listen(() => { | |
console.log('callback'); | |
}); | |
console.log(server.address().port); | |
server.on('error', err => { | |
throw err; | |
}); | |
resolve(server); // I don't want this here. I want it in the listen function | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment