本文整理汇总了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);
}