UNPKG

657 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const is_port_reachable_1 = tslib_1.__importDefault(require("is-port-reachable"));
5/**
6 * Takes in an array of numbers, and returns the first one ith available port.
7 * If no ports are available, return null
8 */
9exports.getFirstActivePort = async (ports) => {
10 for (let i = 0; i < ports.length; i++) {
11 const currentPort = ports[i];
12 if (typeof currentPort !== 'number')
13 return null;
14 if (!(await is_port_reachable_1.default(currentPort))) {
15 return currentPort;
16 }
17 }
18 return null;
19};