Add types for pid-from-port

This commit is contained in:
Dimitri Benin
2018-12-09 16:33:06 +01:00
parent e95e11dcf2
commit 886bf50809
4 changed files with 60 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for pid-from-port 1.1
// Project: https://github.com/kevva/pid-from-port#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = pidFromPort;
/**
* Get PID from a port
* @param port Port to lookup.
*/
declare function pidFromPort(port: number): Promise<number>;
declare namespace pidFromPort {
/**
* Get PIDs for a list of ports.
* @param ports Ports to lookup.
* @returns A `Promise<Map>` with the port as key and the PID as value.
*/
function all(ports: number[]): Promise<Map<number, number>>;
/**
* Get all PIDs from ports.
* @returns A `Promise<Map>` with the port as key and the PID as value.
*/
function list(): Promise<Map<number, number>>;
}
@@ -0,0 +1,10 @@
import pidFromPort = require('pid-from-port');
// $ExpectType Promise<number>
pidFromPort(8080);
// $ExpectType Promise<Map<number, number>>
pidFromPort.all([8080, 22]);
// $ExpectType Promise<Map<number, number>>
pidFromPort.list();
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"pid-from-port-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }