diff --git a/types/network-interfaces/index.d.ts b/types/network-interfaces/index.d.ts new file mode 100644 index 0000000000..99b58a23aa --- /dev/null +++ b/types/network-interfaces/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for network-interfaces 1.1 +// Project: https://github.com/Wizcorp/network-interfaces#readme +// Definitions by: Anders Westberg +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function toIp(interfaceName: string, options: {}): string; +export function toIps(interfaceName: string, options: {}): string[]; +export function fromIp(ip: string, options: {}): string; +export function getInterface(options: {}): string; +export function getInterfaces(options: {}): string[]; diff --git a/types/network-interfaces/network-interfaces-tests.ts b/types/network-interfaces/network-interfaces-tests.ts new file mode 100644 index 0000000000..a4cb71104a --- /dev/null +++ b/types/network-interfaces/network-interfaces-tests.ts @@ -0,0 +1,22 @@ +/// +import * as ni from "network-interfaces"; +import * as os from "os"; + +const options = { + internal: false, // boolean: only acknowledge internal or external addresses (undefined: both) + ipVersion: 4 // integer (4 or 6): only acknowledge addresses of this IP address family (undefined: both) +}; + +function test() { + try { + const ifcName = os.platform() !== "win32" ? "eth0" : "Ethernet"; + const ip = ni.toIp(ifcName, options); + const ipList = ni.toIps(ifcName, options); + let ifc = ni.getInterface(options); + const ifcList = ni.getInterfaces(ifcName); + ifc = ni.fromIp(ip, options); + } catch (e) { + } +} + +test(); diff --git a/types/network-interfaces/tsconfig.json b/types/network-interfaces/tsconfig.json new file mode 100644 index 0000000000..f7067486d8 --- /dev/null +++ b/types/network-interfaces/tsconfig.json @@ -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", + "network-interfaces-tests.ts" + ] +} diff --git a/types/network-interfaces/tslint.json b/types/network-interfaces/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/network-interfaces/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }