1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const 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 | */
|
9 | exports.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 | };
|