1 | /**
|
2 | * portfinder.js typescript definitions.
|
3 | *
|
4 | * (C) 2011, Charlie Robbins
|
5 | */
|
6 |
|
7 | type PortfinderCallback = (err: Error, port: number) => void;
|
8 |
|
9 | interface PortFinderOptions {
|
10 | /**
|
11 | * Host to find available port on.
|
12 | */
|
13 | host?: string;
|
14 | /**
|
15 | * search start port (equals to port when not provided)
|
16 | * This exists because getPort and getPortPromise mutates port state in
|
17 | * recursive calls and doesn't have a way to retrieve begininng port while
|
18 | * searching.
|
19 | */
|
20 | startPort?: number;
|
21 | /**
|
22 | * Minimum port (takes precedence over `basePort`).
|
23 | */
|
24 | port?: number;
|
25 | /**
|
26 | * Maximum port
|
27 | */
|
28 | stopPort?: number;
|
29 | }
|
30 |
|
31 | /**
|
32 | * The lowest port to begin any port search from.
|
33 | */
|
34 | export let basePort: number;
|
35 |
|
36 | /**
|
37 | * Set the lowest port to begin any port search from.
|
38 | */
|
39 | export function setBasePort(port: number): void;
|
40 |
|
41 | /**
|
42 | * The highest port to end any port search from.
|
43 | */
|
44 | export let highestPort: number;
|
45 |
|
46 | /**
|
47 | * Set the higheset port to end any port search from.
|
48 | */
|
49 | export function setHighestPort(port: number): void;
|
50 |
|
51 | /**
|
52 | * Responds with a unbound port on the current machine.
|
53 | */
|
54 | export function getPort(callback: PortfinderCallback): void;
|
55 | export function getPort(options: PortFinderOptions, callback: PortfinderCallback): void;
|
56 |
|
57 | export function getPorts(count: number, options: PortFinderOptions, callback: (err: Error, ports: Array<number>) => void): void;
|
58 |
|
59 | /**
|
60 | * Responds a promise of an unbound port on the current machine.
|
61 | */
|
62 | export function getPortPromise(options?: PortFinderOptions): Promise<number>;
|