poku
Version:
🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.
25 lines (24 loc) • 955 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPIDs = void 0;
const os_js_1 = require("../../parsers/os.js");
const pid_js_1 = require("../../services/pid.js");
const getPIDsByPorts = async (port) => {
const ports = (0, pid_js_1.setPortsAndPIDs)(port);
const PIDs = [];
await Promise.all(ports.map(async (p) => {
PIDs.push(...(await (os_js_1.isWindows
? pid_js_1.getPIDs.windows(p)
: pid_js_1.getPIDs.unix(p))));
}));
return PIDs;
};
const getPIDsByRange = (startsAt, endsAt) => {
const ports = (0, pid_js_1.populateRange)(startsAt, endsAt);
return (0, exports.getPIDs)(ports);
};
/** Returns an array containing the ID of all processes listening to the specified port */
exports.getPIDs = Object.assign(getPIDsByPorts, {
/** Returns an array containing the ID of all processes listening to the specified port range */
range: getPIDsByRange,
});