Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

async-listen

vercel10.1mMIT3.1.0TypeScript support: included

net.Server#listen() helper that returns a Promise for async / await

async, await, es6, http, listen, net, promise, server

readme

async-listen

Promisify server.listen for your HTTP/HTTPS/TCP server.

Install

npm install async-listen

Usage

import listen from 'async-listen';
import { createServer } from 'http';

async function main() {
    const port = 3000;
    const server = createServer();
    const address = await listen(server, port);
    console.log(address); // => URL('http://127.0.0.1:3000')
}

main().catch(console.error);