Bakhtina Sofya b84cb877be 1st comm | 2 недель назад | |
---|---|---|
.. | ||
node_modules | 2 недель назад | |
index.js | 2 недель назад | |
license | 2 недель назад | |
package.json | 2 недель назад | |
readme.md | 2 недель назад |
Get PID from a port
$ npm install pid-from-port
const pidFromPort = require('pid-from-port');
(async () => {
try {
console.log(await pidFromPort(8080));
//=> 1337
const pids = await pidFromPort.all([8080, 22]);
console.log(pids.get(8080));
//=> 1337
console.log(pids.get(22));
//=> 12345
} catch (err) {
console.log(err);
//=> 'Couldn't find a process with port `8080`'
}
})();
Type: number
Port to lookup.
Returns a Promise<Map>
with the port as key and the PID as value.
Type: Array<number>
Ports to lookup.
Get all PIDs from ports.
Returns a Promise<Map>
with the port as key and the PID as value.
MIT © Kevin Martensson