forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netmask.d.ts
47 lines (38 loc) · 1.5 KB
/
netmask.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Type definitions for Netmask 1.0.5
// Project: https://github.com/rs/node-netmask
// Definitions by: Matt Frantz <https://github.com/mhfrantz/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// netmask.d.ts
declare module 'netmask' {
export function long2ip(long: number): string;
export function ip2long(ip: string): number;
export class Netmask {
maskLong: number;
bitmask: number;
netLong: number;
// The number of IP address in the block (eg.: 254)
size: number;
// The address of the network block as a string (eg.: 216.240.32.0)
base: string;
// The netmask as a string (eg.: 255.255.255.0)
mask: string;
// The host mask, the opposite of the netmask (eg.: 0.0.0.255)
hostmask: string;
// The first usable address of the block
first: string;
// The last usable address of the block
last: string;
// The block's broadcast address: the last address of the block (eg.: 192.168.1.255)
broadcast: string;
constructor (netmask: string);
constructor (net: string, mask: string);
// Returns true if the given ip or netmask is contained in the block
contains(ip: string | Netmask | number): boolean;
// Returns the Netmask object for the block which follow this one
next(count?: number): Netmask;
// Evaluate a function on each IP address
forEach(fn: (ip: string, long: number, index: number) => void): void;
// Returns the complete netmask formatted as `base/bitmask`
toString(): string;
}
}