0.0.1 • Published 6 years ago

portproc-core v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

PortProc

A utility to:

  • get the ID of the process currently using a given port
  • get the port currently in use by a given process ID

Installation

npm install --save portproc-core

Usage

const { portToProc, procToPort } = require("portproc");

// Get the PID of the process using port 3000
portToProc(3000)
    .then(proc => console.log("process id: " + proc);

// Get the port that process '54321' is currently using
procToPort(54321)
    .then(port => console.log("port: " + port));

Both utilities take in an integer number, and return a promise.

If you provide a port or process ID and no match can be found, the promise will reject.