mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-23 01:02:54 +00:00
Added typings for network-interfaces (#25027)
* Added typings for network-interfaces * Added typings for network-interfaces * Corrected build errors
This commit is contained in:
parent
a67c35269a
commit
bbca3b76fa
10
types/network-interfaces/index.d.ts
vendored
Normal file
10
types/network-interfaces/index.d.ts
vendored
Normal 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[];
|
||||
22
types/network-interfaces/network-interfaces-tests.ts
Normal file
22
types/network-interfaces/network-interfaces-tests.ts
Normal 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();
|
||||
23
types/network-interfaces/tsconfig.json
Normal file
23
types/network-interfaces/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/network-interfaces/tslint.json
Normal file
1
types/network-interfaces/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user