@types/ip
- Version 1.1.3
- Published
- 5.86 kB
- 1 dependency
- MIT license
Install
npm i @types/ip
yarn add @types/ip
pnpm add @types/ip
Overview
TypeScript definitions for ip
Index
Functions
Interfaces
Functions
function address
address: ( name?: 'public' | 'private' | string, family?: 'ipv4' | 'ipv6') => string;
Get the address for the network interface on the current system with the specified 'name'. If no interface name is specified, the first IPv4 address or loopback address is returned.
Parameter name
The name can be any named interface, or 'public' or 'private'.
Parameter family
The family can be either "ipv4" or "ipv6". Default: "ipv4".
function cidr
cidr: (cidr: string) => string;
Get the network ID IP address from an IP address in CIDR notation.
function cidrSubnet
cidrSubnet: (cidr: string) => SubnetInfo;
Get the subnet information.
Parameter cidr
CIDR address.
function fromLong
fromLong: (ip: number) => string;
Convert an IPv4 IP address from its the long numeric value to a string.
function fromPrefixLen
fromPrefixLen: (prefixLength: number, family?: 'ipv4' | 'ipv6') => string;
Get the subnet mask from a CIDR prefix length.
Parameter family
The IP family is infered from the prefixLength, but can be explicity specified as either "ipv4" or "ipv6".
function isEqual
isEqual: (ip1: string, ip2: string) => boolean;
Check two IP address are the same.
function isLoopback
isLoopback: (ip: string) => boolean;
Check whether an IP is a loopback address.
function isPrivate
isPrivate: (ip: string) => boolean;
Check whether an IP is within a private IP address range.
function isPublic
isPublic: (ip: string) => boolean;
Check whether an IP is within a public IP address range.
function isV4Format
isV4Format: (ip: string) => boolean;
Check whether an IP is a IPv4 address.
function isV6Format
isV6Format: (ip: string) => boolean;
Check whether an IP is a IPv6 address.
function loopback
loopback: (family?: 'ipv4' | 'ipv6') => string;
Get the loopback address for an IP family.
Parameter family
The family can be either "ipv4" or "ipv6". Default: "ipv4".
function mask
mask: (ip: string, mask: string) => string;
Get the network ID IP address from an IP address and its subnet mask.
function not
not: (ip: string) => string;
Get the bitwise inverse (NOT every octet) of an IP address or subnet mask.
function or
or: (ip: string, mask: string) => string;
Get the bitwise OR of two IP addresses (usually an IP address and a subnet mask).
function subnet
subnet: (ip: string, subnet: string) => SubnetInfo;
Get the subnet information.
Parameter ip
IP address.
Parameter subnet
Subnet address.
function toBuffer
toBuffer: (ip: string, buffer?: Buffer, offset?: number) => Buffer;
Convert an IP string into a buffer.
function toLong
toLong: (ip: string) => number;
Convert a string IPv4 IP address to the equivalent long numeric value.
function toString
toString: (ip: Buffer, offset?: number, length?: number) => string;
Convert an IP buffer into a string.
Interfaces
interface SubnetInfo
interface SubnetInfo {}
property broadcastAddress
broadcastAddress: string;
property firstAddress
firstAddress: string;
property lastAddress
lastAddress: string;
property length
length: number;
property networkAddress
networkAddress: string;
property numHosts
numHosts: number;
property subnetMask
subnetMask: string;
property subnetMaskLength
subnetMaskLength: number;
method contains
contains: (ip: string) => boolean;
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/ip
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/ip)
- HTML<a href="https://www.jsdocs.io/package/@types/ip"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3835 ms. - Missing or incorrect documentation? Open an issue for this package.