本文整理匯總了TypeScript中portscanner.findAPortNotInUse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript findAPortNotInUse函數的具體用法?TypeScript findAPortNotInUse怎麽用?TypeScript findAPortNotInUse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了findAPortNotInUse函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getPort
export function getPort(host: string, port: number|string, max: number|string|null, cb: PortLookupCb) {
portScanner.findAPortNotInUse(
port,
max,
{
host: host,
timeout: 1000
},
cb
);
}
示例2: assert
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
示例3: function
getPort: function (port, max, cb) {
portScanner.findAPortNotInUse(port, max, {
host: 'localhost',
timeout: 1000
}, cb);
},
示例4: freePort
static freePort(initialPort: number, host?: string): Promise<number> {
return portscanner.findAPortNotInUse(initialPort, host);
}