Added typings for network-interfaces (#25027)

* Added typings for network-interfaces

* Added typings for network-interfaces

* Corrected build errors
This commit is contained in:
anderswestberg 2018-04-17 00:39:06 +02:00 committed by Ryan Cavanaugh
parent a67c35269a
commit bbca3b76fa
4 changed files with 56 additions and 0 deletions

10
types/network-interfaces/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
// Type definitions for network-interfaces 1.1
// Project: https://github.com/Wizcorp/network-interfaces#readme
// Definitions by: Anders Westberg <https://github.com/anderswestberg>
// 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[];

View File

@ -0,0 +1,22 @@
/// <reference types="node" />
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();

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",
"network-interfaces-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }