mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 20:21:46 +00:00
refacto(portscanner): rename node-portscanner to match npm package name (#18465)
This commit is contained in:
Vendored
-56
@@ -1,56 +0,0 @@
|
||||
// Type definitions for portscanner 2.1
|
||||
// Project: https://github.com/baalexander/node-portscanner
|
||||
// Definitions by: Douglas Duteil <https://github.com/douglasduteil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'portscanner' {
|
||||
type Status = 'open' | 'closed';
|
||||
|
||||
type PortCallback = (error: Error | null, port: number) => void;
|
||||
type StatusCallback = (error: Error | null, port: Status) => void;
|
||||
|
||||
interface Options {
|
||||
host?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
function checkPortStatus(port: number): Promise<Status>;
|
||||
|
||||
function checkPortStatus(port: number, host: string): Promise<Status>;
|
||||
function checkPortStatus(port: number, opts: Options): Promise<Status>;
|
||||
function checkPortStatus(port: number, checkPortCallback: StatusCallback): void;
|
||||
|
||||
function checkPortStatus(port: number, host: string, opts: Options): Promise<Status>;
|
||||
function checkPortStatus(port: number, host: string, checkPortCallback: StatusCallback): void;
|
||||
function checkPortStatus(port: number, opts: Options, checkPortCallback: StatusCallback): void;
|
||||
|
||||
function checkPortStatus(port: number, host: string, opts: Options, checkPortCallback: StatusCallback): void;
|
||||
|
||||
function findAPortNotInUse(portList: number[]): Promise<number>;
|
||||
function findAPortNotInUse(startPort: number): Promise<number>;
|
||||
|
||||
function findAPortNotInUse(portList: number[], findPortCallback: PortCallback): void;
|
||||
function findAPortNotInUse(portList: number[], host: string): Promise<number>;
|
||||
function findAPortNotInUse(startPort: number, findPortCallback: PortCallback): void;
|
||||
function findAPortNotInUse(startPort: number, host: string): Promise<number>;
|
||||
function findAPortNotInUse(startPort: number, endPort: number): Promise<number>;
|
||||
|
||||
function findAPortNotInUse(startPort: number, endPort: number, host: string): Promise<number>;
|
||||
function findAPortNotInUse(startPort: number, endPort: number, findPortCallback: PortCallback): void;
|
||||
|
||||
function findAPortNotInUse(startPort: number, endPort: number, host: string, findPortCallback: PortCallback): void;
|
||||
|
||||
function findAPortInUse(portList: number[]): Promise<number>;
|
||||
function findAPortInUse(startPort: number): Promise<number>;
|
||||
|
||||
function findAPortInUse(portList: number[], findPortCallback: PortCallback): void;
|
||||
function findAPortInUse(portList: number[], host: string): Promise<number>;
|
||||
function findAPortInUse(startPort: number, findPortCallback: PortCallback): void;
|
||||
function findAPortInUse(startPort: number, host: string): Promise<number>;
|
||||
function findAPortInUse(startPort: number, endPort: number): Promise<number>;
|
||||
|
||||
function findAPortInUse(startPort: number, endPort: number, host: string): Promise<number>;
|
||||
function findAPortInUse(startPort: number, endPort: number, findPortCallback: PortCallback): void;
|
||||
|
||||
function findAPortInUse(startPort: number, endPort: number, host: string, findPortCallback: PortCallback): void;
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
import * as portscanner from 'portscanner';
|
||||
declare function assert(cond: boolean): void;
|
||||
|
||||
const checkPortCallback = (error: Error | null, status: portscanner.Status) => {
|
||||
assert(error === null);
|
||||
error && assert(error.message === '');
|
||||
assert(status === 'open');
|
||||
assert(status === 'closed');
|
||||
};
|
||||
|
||||
const assertStatus = (status: portscanner.Status) => {
|
||||
assert(status === 'open');
|
||||
assert(status === 'closed');
|
||||
};
|
||||
|
||||
portscanner.checkPortStatus(3000).then(assertStatus);
|
||||
|
||||
portscanner.checkPortStatus(3000, '127.0.0.1').then(assertStatus);
|
||||
portscanner.checkPortStatus(3000, { host: '127.0.0.1' }).then(assertStatus);
|
||||
portscanner.checkPortStatus(3000, { timeout: 400 }).then(assertStatus);
|
||||
portscanner.checkPortStatus(3000, checkPortCallback);
|
||||
|
||||
portscanner.checkPortStatus(3000, { host: '127.0.0.1' }, checkPortCallback);
|
||||
portscanner.checkPortStatus(3000, { timeout: 400 }, checkPortCallback);
|
||||
portscanner.checkPortStatus(3000, '127.0.0.1', checkPortCallback);
|
||||
|
||||
portscanner.checkPortStatus(3000, '127.0.0.1', { timeout: 400 }).then(assertStatus);
|
||||
portscanner.checkPortStatus(3000, '127.0.0.1', { timeout: 400 }, checkPortCallback);
|
||||
|
||||
const findPortCallback = (error: Error | null, port: number) => {
|
||||
assert(error === null);
|
||||
error && assert(error.message === '');
|
||||
assert(port === 3005);
|
||||
};
|
||||
|
||||
const assertPort = (port: number) => {
|
||||
assert(port === 3005);
|
||||
};
|
||||
|
||||
// one argument
|
||||
portscanner.findAPortNotInUse([3000, 3005, 3006]).then(assertPort);
|
||||
portscanner.findAPortNotInUse(3000).then(assertPort);
|
||||
|
||||
// two arguments
|
||||
portscanner.findAPortNotInUse([3000, 3005, 3006], findPortCallback);
|
||||
portscanner.findAPortNotInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);
|
||||
|
||||
portscanner.findAPortNotInUse(3000, findPortCallback);
|
||||
portscanner.findAPortNotInUse(3000, '127.0.0.1').then(assertPort);
|
||||
portscanner.findAPortNotInUse(3000, 3010).then(assertPort);
|
||||
|
||||
// three arguments
|
||||
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1').then(assertPort);
|
||||
portscanner.findAPortNotInUse(3000, 3010, findPortCallback);
|
||||
|
||||
// four argumentss
|
||||
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', findPortCallback);
|
||||
|
||||
// one argument
|
||||
portscanner.findAPortInUse([3000, 3005, 3006]).then(assertPort);
|
||||
portscanner.findAPortInUse(3000).then(assertPort);
|
||||
|
||||
// two arguments
|
||||
portscanner.findAPortInUse([3000, 3005, 3006], findPortCallback);
|
||||
portscanner.findAPortInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);
|
||||
|
||||
portscanner.findAPortInUse(3000, findPortCallback);
|
||||
portscanner.findAPortInUse(3000, '127.0.0.1').then(assertPort);
|
||||
portscanner.findAPortInUse(3000, 3010).then(assertPort);
|
||||
|
||||
// three arguments
|
||||
portscanner.findAPortInUse(3000, 3010, '127.0.0.1').then(assertPort);
|
||||
portscanner.findAPortInUse(3000, 3010, findPortCallback);
|
||||
|
||||
// four argumentss
|
||||
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', findPortCallback);
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
// Type definitions for portscanner 2.1
|
||||
// Project: https://github.com/baalexander/node-portscanner
|
||||
// Definitions by: Douglas Duteil <https://github.com/douglasduteil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type Status = 'open' | 'closed';
|
||||
|
||||
export type PortCallback = (error: Error | null, port: number) => void;
|
||||
export type StatusCallback = (error: Error | null, port: Status) => void;
|
||||
|
||||
export interface Options {
|
||||
host?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export function checkPortStatus(port: number): Promise<Status>;
|
||||
|
||||
export function checkPortStatus(port: number, host: string): Promise<Status>;
|
||||
export function checkPortStatus(port: number, opts: Options): Promise<Status>;
|
||||
export function checkPortStatus(port: number, checkPortCallback: StatusCallback): void;
|
||||
|
||||
export function checkPortStatus(port: number, host: string, opts: Options): Promise<Status>;
|
||||
export function checkPortStatus(port: number, host: string, checkPortCallback: StatusCallback): void;
|
||||
export function checkPortStatus(port: number, opts: Options, checkPortCallback: StatusCallback): void;
|
||||
|
||||
export function checkPortStatus(port: number, host: string, opts: Options, checkPortCallback: StatusCallback): void;
|
||||
|
||||
export function findAPortNotInUse(portList: number[]): Promise<number>;
|
||||
export function findAPortNotInUse(startPort: number): Promise<number>;
|
||||
|
||||
export function findAPortNotInUse(portList: number[], findPortCallback: PortCallback): void;
|
||||
export function findAPortNotInUse(portList: number[], host: string): Promise<number>;
|
||||
export function findAPortNotInUse(startPort: number, findPortCallback: PortCallback): void;
|
||||
export function findAPortNotInUse(startPort: number, host: string): Promise<number>;
|
||||
export function findAPortNotInUse(startPort: number, endPort: number): Promise<number>;
|
||||
|
||||
export function findAPortNotInUse(startPort: number, endPort: number, host: string): Promise<number>;
|
||||
export function findAPortNotInUse(startPort: number, endPort: number, findPortCallback: PortCallback): void;
|
||||
|
||||
export function findAPortNotInUse(startPort: number, endPort: number, host: string, findPortCallback: PortCallback): void;
|
||||
|
||||
export function findAPortInUse(portList: number[]): Promise<number>;
|
||||
export function findAPortInUse(startPort: number): Promise<number>;
|
||||
|
||||
export function findAPortInUse(portList: number[], findPortCallback: PortCallback): void;
|
||||
export function findAPortInUse(portList: number[], host: string): Promise<number>;
|
||||
export function findAPortInUse(startPort: number, findPortCallback: PortCallback): void;
|
||||
export function findAPortInUse(startPort: number, host: string): Promise<number>;
|
||||
export function findAPortInUse(startPort: number, endPort: number): Promise<number>;
|
||||
|
||||
export function findAPortInUse(startPort: number, endPort: number, host: string): Promise<number>;
|
||||
export function findAPortInUse(startPort: number, endPort: number, findPortCallback: PortCallback): void;
|
||||
|
||||
export function findAPortInUse(startPort: number, endPort: number, host: string, findPortCallback: PortCallback): void;
|
||||
@@ -0,0 +1,77 @@
|
||||
import { checkPortStatus, findAPortNotInUse, findAPortInUse, Status } from 'portscanner';
|
||||
|
||||
declare function assert(cond: boolean): void;
|
||||
|
||||
const checkPortCallback = (error: Error | null, status: Status) => {
|
||||
assert(error === null);
|
||||
error && assert(error.message === '');
|
||||
assert(status === 'open');
|
||||
assert(status === 'closed');
|
||||
};
|
||||
|
||||
const assertStatus = (status: Status) => {
|
||||
assert(status === 'open');
|
||||
assert(status === 'closed');
|
||||
};
|
||||
|
||||
checkPortStatus(3000).then(assertStatus);
|
||||
|
||||
checkPortStatus(3000, '127.0.0.1').then(assertStatus);
|
||||
checkPortStatus(3000, { host: '127.0.0.1' }).then(assertStatus);
|
||||
checkPortStatus(3000, { timeout: 400 }).then(assertStatus);
|
||||
checkPortStatus(3000, checkPortCallback);
|
||||
|
||||
checkPortStatus(3000, { host: '127.0.0.1' }, checkPortCallback);
|
||||
checkPortStatus(3000, { timeout: 400 }, checkPortCallback);
|
||||
checkPortStatus(3000, '127.0.0.1', checkPortCallback);
|
||||
|
||||
checkPortStatus(3000, '127.0.0.1', { timeout: 400 }).then(assertStatus);
|
||||
checkPortStatus(3000, '127.0.0.1', { timeout: 400 }, checkPortCallback);
|
||||
|
||||
const findPortCallback = (error: Error | null, port: number) => {
|
||||
assert(error === null);
|
||||
error && assert(error.message === '');
|
||||
assert(port === 3005);
|
||||
};
|
||||
|
||||
const assertPort = (port: number) => {
|
||||
assert(port === 3005);
|
||||
};
|
||||
|
||||
// one argument
|
||||
findAPortNotInUse([3000, 3005, 3006]).then(assertPort);
|
||||
findAPortNotInUse(3000).then(assertPort);
|
||||
|
||||
// two arguments
|
||||
findAPortNotInUse([3000, 3005, 3006], findPortCallback);
|
||||
findAPortNotInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);
|
||||
|
||||
findAPortNotInUse(3000, findPortCallback);
|
||||
findAPortNotInUse(3000, '127.0.0.1').then(assertPort);
|
||||
findAPortNotInUse(3000, 3010).then(assertPort);
|
||||
|
||||
// three arguments
|
||||
findAPortNotInUse(3000, 3010, '127.0.0.1').then(assertPort);
|
||||
findAPortNotInUse(3000, 3010, findPortCallback);
|
||||
|
||||
// four argumentss
|
||||
findAPortNotInUse(3000, 3010, '127.0.0.1', findPortCallback);
|
||||
|
||||
// one argument
|
||||
findAPortInUse([3000, 3005, 3006]).then(assertPort);
|
||||
findAPortInUse(3000).then(assertPort);
|
||||
|
||||
// two arguments
|
||||
findAPortInUse([3000, 3005, 3006], findPortCallback);
|
||||
findAPortInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);
|
||||
|
||||
findAPortInUse(3000, findPortCallback);
|
||||
findAPortInUse(3000, '127.0.0.1').then(assertPort);
|
||||
findAPortInUse(3000, 3010).then(assertPort);
|
||||
|
||||
// three arguments
|
||||
findAPortInUse(3000, 3010, '127.0.0.1').then(assertPort);
|
||||
findAPortInUse(3000, 3010, findPortCallback);
|
||||
|
||||
// four argumentss
|
||||
findAPortInUse(3000, 3010, '127.0.0.1', findPortCallback);
|
||||
@@ -17,6 +17,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-portscanner-tests.ts"
|
||||
"portscanner-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user