v1.2.2 - Fix network error on background, auto-retry streaming with reconnect
This commit is contained in:
1
node_modules/find-free-ports/.browserslistrc
generated
vendored
Normal file
1
node_modules/find-free-ports/.browserslistrc
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
maintained node versions
|
||||
20
node_modules/find-free-ports/LICENSE.txt
generated
vendored
Normal file
20
node_modules/find-free-ports/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright 2017 Sam Vervaeck
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
99
node_modules/find-free-ports/README.md
generated
vendored
Normal file
99
node_modules/find-free-ports/README.md
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
This is a very small package that allows developers to find free ports
|
||||
on the local system. Unlike most other "find-free-port" utilities, this library
|
||||
allows scanning for multiple free ports at once, making sure that there are no
|
||||
doubles in the result.
|
||||
|
||||
✔️ TypeScript support
|
||||
|
||||
✔️ No dependencies
|
||||
|
||||
✔️ Should work on all major NodeJS versions
|
||||
|
||||
✔️ Now automatically tested for mistakes
|
||||
|
||||
This library has been benchmarked and parallelises the port checks using a
|
||||
customisable number of workers for optimal performance. The alogithm does
|
||||
**not** create a new anonymous socket for each port, but instead iterates in
|
||||
parallell over the system's port numbers. This is both faster and less
|
||||
resource-intensive.
|
||||
|
||||
🔍 Found an issue? Please let me know in the [issue tracker][1] and we'll get
|
||||
it fixed ASAP.
|
||||
|
||||
[1]: https://github.com/samvv/node-find-free-ports/issues
|
||||
|
||||
```
|
||||
npm i find-free-ports
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Import the library:
|
||||
|
||||
```js
|
||||
import findFreePorts from "find-free-ports"
|
||||
```
|
||||
or
|
||||
```js
|
||||
const findFreePorts = require('find-free-ports');
|
||||
```
|
||||
|
||||
Next, call the main function with the amount of free ports you need:
|
||||
|
||||
```js
|
||||
async function startMultipleServers() {
|
||||
const [a, b, c, d] = await findFreePorts(4);
|
||||
// now do something interesting with the new ports ...
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### findFreePorts(count?, opts?)
|
||||
|
||||
```js
|
||||
import { findFreePorts } from "find-free-ports"
|
||||
```
|
||||
|
||||
Search for the specified amount of free ports on the local machine. If `count`
|
||||
is left unspecified, it defaults to `1`. `opts` may be a dictionary containing one
|
||||
of the following keys:
|
||||
|
||||
- `isFree`: custom function that is used to check whether the given port is free
|
||||
- `startPort`: start scanning for free ports starting from this port number.
|
||||
Defaults to `1025`.
|
||||
- `endPort`: prevent the scanner from exceeding this port number. Defaults to
|
||||
`65535`.
|
||||
- `jobCount`: how much workers that may at most be looking for free ports
|
||||
|
||||
### isFreePort(port)
|
||||
|
||||
```js
|
||||
import { isFreePort } from "find-free-ports"
|
||||
```
|
||||
|
||||
Check whether the given port is free by trying to set up a socket.
|
||||
|
||||
This function returns a promise containing either `true` or `false` depending
|
||||
on whether the port was available.
|
||||
|
||||
### FindFreePortsOptions
|
||||
|
||||
```js
|
||||
import { FindFreePortsOptions } from "find-free-ports"
|
||||
```
|
||||
|
||||
A TypeScript interface that lists all valid options that may be passed as the
|
||||
`opts` parameter to `findFreePorts()`.
|
||||
|
||||
## Similar Packages
|
||||
|
||||
- [portfinder](https://www.npmjs.com/package/portfinder)
|
||||
- [get-port](https://www.npmjs.com/package/get-port)
|
||||
- [find-free-port](https://www.npmjs.com/package/find-free-port)
|
||||
- [freeport](https://www.npmjs.com/package/freeport)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License
|
||||
14
node_modules/find-free-ports/index.d.ts
generated
vendored
Normal file
14
node_modules/find-free-ports/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export interface FindFreePortsOptions {
|
||||
startPort?: number;
|
||||
endPort?: number;
|
||||
jobCount?: number;
|
||||
isFree?: (port: number) => Promise<boolean>;
|
||||
}
|
||||
export declare function findFreePorts(count?: number, { endPort, startPort, jobCount, isFree }?: FindFreePortsOptions): Promise<number[]>;
|
||||
export declare namespace findFreePorts {
|
||||
var findFreePorts: typeof import(".").findFreePorts;
|
||||
var isFreePort: typeof import(".").isFreePort;
|
||||
}
|
||||
export declare function isFreePort(port: number): Promise<boolean>;
|
||||
export default findFreePorts;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/find-free-ports/index.d.ts.map
generated
vendored
Normal file
1
node_modules/find-free-ports/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C;AAQD,wBAAsB,aAAa,CAAC,KAAK,SAAI,EAAE,EAC7C,OAAkB,EAClB,SAAoB,EACpB,QAA4B,EAC5B,MAAmB,EACpB,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAsC/C;yBA3CqB,aAAa;;;;AA6CnC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAazD;AAED,eAAe,aAAa,CAAC"}
|
||||
78
node_modules/find-free-ports/index.js
generated
vendored
Normal file
78
node_modules/find-free-ports/index.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.findFreePorts = findFreePorts;
|
||||
exports.isFreePort = isFreePort;
|
||||
var _os = _interopRequireDefault(require("os"));
|
||||
var _net = _interopRequireDefault(require("net"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
const MIN_PORT = 1025;
|
||||
const MAX_PORT = 65535;
|
||||
const DEFAULT_JOB_COUNT = _os.default.cpus().length;
|
||||
function clamp(value, min, max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
async function findFreePorts(count = 1, {
|
||||
endPort = MAX_PORT,
|
||||
startPort = MIN_PORT,
|
||||
jobCount = DEFAULT_JOB_COUNT,
|
||||
isFree = isFreePort
|
||||
} = {}) {
|
||||
if (count > endPort - startPort) {
|
||||
throw new Error(`Could not find free ports: the range of allowed ports is not large enough for the requested amount of ports to find.`);
|
||||
}
|
||||
const portInterval = Math.ceil((endPort - startPort) / jobCount);
|
||||
const ports = [];
|
||||
const jobPromises = [];
|
||||
for (let i = 0; i < jobCount; i++) {
|
||||
jobPromises.push(scanRange(startPort + portInterval * i, Math.min(endPort, startPort + portInterval * (i + 1))));
|
||||
}
|
||||
await Promise.all(jobPromises);
|
||||
if (ports.length < count) {
|
||||
throw new Error(`Could not find free ports: there were not enough ports available.`);
|
||||
}
|
||||
return ports;
|
||||
async function scanRange(startPort, endPort) {
|
||||
for (let port = startPort; port < endPort; port++) {
|
||||
if (ports.length >= count) {
|
||||
break;
|
||||
}
|
||||
if (await isFree(port)) {
|
||||
if (ports.length >= count) {
|
||||
break;
|
||||
}
|
||||
ports.push(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function isFreePort(port) {
|
||||
return new Promise((accept, reject) => {
|
||||
const sock = _net.default.createConnection(port);
|
||||
sock.once('connect', () => {
|
||||
sock.end();
|
||||
accept(false);
|
||||
});
|
||||
sock.once('error', e => {
|
||||
sock.destroy();
|
||||
if (e.code === 'ECONNREFUSED') {
|
||||
accept(true);
|
||||
} else {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
var _default = findFreePorts;
|
||||
exports.default = _default;
|
||||
if (typeof module.exports !== 'undefined') {
|
||||
module.exports = findFreePorts;
|
||||
findFreePorts.findFreePorts = findFreePorts;
|
||||
findFreePorts.isFreePort = isFreePort;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/find-free-ports/index.js.map
generated
vendored
Normal file
1
node_modules/find-free-ports/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
88
node_modules/find-free-ports/index.ts
generated
vendored
Normal file
88
node_modules/find-free-ports/index.ts
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
import os from "os"
|
||||
import net from "net"
|
||||
|
||||
const MIN_PORT = 1025;
|
||||
const MAX_PORT = 65535;
|
||||
const DEFAULT_JOB_COUNT = os.cpus().length;
|
||||
|
||||
export interface FindFreePortsOptions {
|
||||
startPort?: number;
|
||||
endPort?: number;
|
||||
jobCount?: number;
|
||||
isFree?: (port: number) => Promise<boolean>;
|
||||
}
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
export async function findFreePorts(count = 1, {
|
||||
endPort = MAX_PORT,
|
||||
startPort = MIN_PORT,
|
||||
jobCount = DEFAULT_JOB_COUNT,
|
||||
isFree = isFreePort
|
||||
}: FindFreePortsOptions = {}): Promise<number[]> {
|
||||
|
||||
if (count > (endPort - startPort)) {
|
||||
throw new Error(`Could not find free ports: the range of allowed ports is not large enough for the requested amount of ports to find.`);
|
||||
}
|
||||
|
||||
const portInterval = Math.ceil((endPort - startPort) / jobCount);
|
||||
|
||||
const ports: number[] = [];
|
||||
const jobPromises: Array<Promise<void>> = [];
|
||||
|
||||
for (let i = 0; i < jobCount; i++) {
|
||||
jobPromises.push(scanRange(startPort + portInterval * i, Math.min(endPort, startPort + portInterval * (i+1))));
|
||||
}
|
||||
|
||||
await Promise.all(jobPromises);
|
||||
|
||||
if (ports.length < count) {
|
||||
throw new Error(`Could not find free ports: there were not enough ports available.`);
|
||||
}
|
||||
|
||||
return ports;
|
||||
|
||||
async function scanRange(startPort: number, endPort: number) {
|
||||
for (let port = startPort; port < endPort; port++) {
|
||||
if (ports.length >= count) {
|
||||
break;
|
||||
}
|
||||
if (await isFree(port)) {
|
||||
|
||||
if (ports.length >= count) {
|
||||
break;
|
||||
}
|
||||
ports.push(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function isFreePort(port: number): Promise<boolean> {
|
||||
return new Promise((accept, reject) => {
|
||||
const sock = net.createConnection(port);
|
||||
sock.once('connect', () => { sock.end(); accept(false); });
|
||||
sock.once('error', (e: NodeJS.ErrnoException) => {
|
||||
sock.destroy();
|
||||
if (e.code === 'ECONNREFUSED') {
|
||||
accept(true)
|
||||
} else {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default findFreePorts;
|
||||
|
||||
if (typeof(module.exports) !== 'undefined') {
|
||||
module.exports = findFreePorts;
|
||||
findFreePorts.findFreePorts = findFreePorts;
|
||||
findFreePorts.isFreePort = isFreePort;
|
||||
}
|
||||
41
node_modules/find-free-ports/package.json
generated
vendored
Normal file
41
node_modules/find-free-ports/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "find-free-ports",
|
||||
"version": "3.1.1",
|
||||
"description": "Find multiple free ports on localhost",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"source": "index.ts",
|
||||
"scripts": {
|
||||
"prepare": "tsc && babel --extensions '.ts' index.ts tests.ts --out-dir . --source-maps",
|
||||
"watch": "concurrently 'ava tests.js --watch' 'babel --watch --extensions .ts index.ts tests.ts --out-dir .'",
|
||||
"test": "ava tests.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/samvv/node-find-free-ports.git"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"port",
|
||||
"networking",
|
||||
"server",
|
||||
"client",
|
||||
"library"
|
||||
],
|
||||
"author": "Sam Vervaeck",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/samvv/node-find-free-ports/issues"
|
||||
},
|
||||
"homepage": "https://github.com/samvv/node-find-free-ports#readme",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.21.0",
|
||||
"@babel/core": "^7.21.4",
|
||||
"@babel/preset-env": "^7.21.4",
|
||||
"@babel/preset-typescript": "^7.21.4",
|
||||
"@types/node": "^18.15.11",
|
||||
"ava": "^5.2.0",
|
||||
"concurrently": "^8.0.1",
|
||||
"typescript": "^5.0.4"
|
||||
}
|
||||
}
|
||||
2
node_modules/find-free-ports/tests.d.ts
generated
vendored
Normal file
2
node_modules/find-free-ports/tests.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=tests.d.ts.map
|
||||
1
node_modules/find-free-ports/tests.d.ts.map
generated
vendored
Normal file
1
node_modules/find-free-ports/tests.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["tests.ts"],"names":[],"mappings":""}
|
||||
89
node_modules/find-free-ports/tests.js
generated
vendored
Normal file
89
node_modules/find-free-ports/tests.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
var _ava = _interopRequireDefault(require("ava"));
|
||||
var _net = _interopRequireDefault(require("net"));
|
||||
var _index = require("./index");
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
const PORT_COUNT = 1000;
|
||||
function isUnique(array) {
|
||||
const set = new Set();
|
||||
for (const element of array) {
|
||||
if (set.has(element)) {
|
||||
return false;
|
||||
}
|
||||
set.add(element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function listen(server, port) {
|
||||
return new Promise((accept, reject) => {
|
||||
server.once('error', reject);
|
||||
server.listen(port, () => {
|
||||
accept(server.address().port);
|
||||
});
|
||||
});
|
||||
}
|
||||
function closeServer(server) {
|
||||
return new Promise((accept, reject) => {
|
||||
server.close(err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
accept();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
(0, _ava.default)('findFreePorts() crashes properly when there are not enough free ports within the given range', async t => {
|
||||
await t.throwsAsync(() => (0, _index.findFreePorts)(10, {
|
||||
startPort: 65530
|
||||
}));
|
||||
await t.throwsAsync(() => (0, _index.findFreePorts)(3, {
|
||||
startPort: 1024,
|
||||
endPort: 1026
|
||||
}));
|
||||
});
|
||||
(0, _ava.default)('searches for one port by default', async t => {
|
||||
const ports = await (0, _index.findFreePorts)();
|
||||
t.assert(ports.length === 1);
|
||||
t.truthy(await (0, _index.isFreePort)(ports[0]));
|
||||
});
|
||||
(0, _ava.default)('can find a few ports when requested', async t => {
|
||||
const ports = await (0, _index.findFreePorts)(3);
|
||||
t.assert(ports.length === 3);
|
||||
t.assert(isUnique(ports));
|
||||
});
|
||||
(0, _ava.default)('can find a large amount of unique free ports', async t => {
|
||||
const ports = await (0, _index.findFreePorts)(PORT_COUNT);
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
(0, _ava.default)('can run with only one job specified', async t => {
|
||||
const ports = await (0, _index.findFreePorts)(PORT_COUNT, {
|
||||
jobCount: 1
|
||||
});
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
(0, _ava.default)('can run with exactly two jobs', async t => {
|
||||
const ports = await (0, _index.findFreePorts)(PORT_COUNT, {
|
||||
jobCount: 2
|
||||
});
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
(0, _ava.default)('isFree() detects when a port is in use', async t => {
|
||||
t.plan(1);
|
||||
const server = _net.default.createServer();
|
||||
const port = await listen(server, undefined);
|
||||
t.falsy(await (0, _index.isFreePort)(port));
|
||||
await closeServer(server);
|
||||
});
|
||||
(0, _ava.default)('isFree() detects when a port is free', async t => {
|
||||
t.plan(1);
|
||||
const server = _net.default.createServer();
|
||||
const port = await listen(server);
|
||||
await closeServer(server);
|
||||
t.truthy(await (0, _index.isFreePort)(port));
|
||||
});
|
||||
//# sourceMappingURL=tests.js.map
|
||||
1
node_modules/find-free-ports/tests.js.map
generated
vendored
Normal file
1
node_modules/find-free-ports/tests.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
93
node_modules/find-free-ports/tests.ts
generated
vendored
Normal file
93
node_modules/find-free-ports/tests.ts
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
import test from "ava"
|
||||
|
||||
import net from "net"
|
||||
|
||||
import { findFreePorts, isFreePort } from './index';
|
||||
|
||||
const PORT_COUNT = 1000;
|
||||
|
||||
function isUnique<T>(array: T[]): boolean {
|
||||
const set = new Set();
|
||||
for (const element of array) {
|
||||
if (set.has(element)) {
|
||||
return false;
|
||||
}
|
||||
set.add(element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function listen(server: net.Server, port?: number): Promise<number> {
|
||||
return new Promise((accept, reject) => {
|
||||
server.once('error', reject);
|
||||
server.listen(port, () => {
|
||||
accept((server.address() as net.AddressInfo).port);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function closeServer(server: net.Server) {
|
||||
return new Promise<void>((accept, reject) => {
|
||||
server.close(err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
accept();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
test('findFreePorts() crashes properly when there are not enough free ports within the given range', async (t) => {
|
||||
await t.throwsAsync(() => findFreePorts(10, { startPort: 65530 }));
|
||||
await t.throwsAsync(() => findFreePorts(3, { startPort: 1024, endPort: 1026 }));
|
||||
})
|
||||
|
||||
test('searches for one port by default', async (t) => {
|
||||
const ports = await findFreePorts();
|
||||
t.assert(ports.length === 1);
|
||||
t.truthy(await isFreePort(ports[0]));
|
||||
});
|
||||
|
||||
test('can find a few ports when requested', async (t) => {
|
||||
const ports = await findFreePorts(3);
|
||||
t.assert(ports.length === 3);
|
||||
t.assert(isUnique(ports));
|
||||
});
|
||||
|
||||
test('can find a large amount of unique free ports', async (t) => {
|
||||
const ports = await findFreePorts(PORT_COUNT);
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
|
||||
test('can run with only one job specified', async (t) => {
|
||||
const ports = await findFreePorts(PORT_COUNT, { jobCount: 1 });
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
|
||||
test('can run with exactly two jobs', async (t) => {
|
||||
const ports = await findFreePorts(PORT_COUNT, { jobCount: 2 });
|
||||
t.assert(ports.length === PORT_COUNT);
|
||||
t.truthy(isUnique(ports));
|
||||
});
|
||||
|
||||
test('isFree() detects when a port is in use', async (t) => {
|
||||
t.plan(1);
|
||||
const server = net.createServer();
|
||||
const port = await listen(server, undefined);
|
||||
t.falsy(await isFreePort(port));
|
||||
await closeServer(server);
|
||||
});
|
||||
|
||||
test('isFree() detects when a port is free', async (t) => {
|
||||
t.plan(1);
|
||||
const server = net.createServer();
|
||||
const port = await listen(server);
|
||||
await closeServer(server);
|
||||
t.truthy(await isFreePort(port));
|
||||
});
|
||||
|
||||
17
node_modules/find-free-ports/tsconfig.json
generated
vendored
Normal file
17
node_modules/find-free-ports/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ES2020",
|
||||
"target": "ES2020",
|
||||
"strict": true,
|
||||
"moduleResolution": "Node",
|
||||
"esModuleInterop": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["index.ts", "tests.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user