open-port-host
2.0.0 • Public • Published open-port-host
Find a number of open ports in a range by host name.
Example:
const findPortHost = require('find-port-host');
const options = {
start: 8000,
end: 8100,
host: 'localhost',
count: 2
};
findPortHost(options)
.then(reserved => {
console.log(`Found ports and reserved the following:`);
console.log(reserved);
})
.catch(err => {
throw new Error(err);
});
These ports are now closed (reserved), and passed back. To use the reserved addresses:
findPortHost(options)
.then(reserved => {
reserved[0].server.once('close', () => {
httpServer.listen(reserved[0].port, options.host);
});
reservedBrowserSyncAddress.server.close();
});
Package Sidebar
Install
Weekly Downloads