llibipaddress
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

IPv4/IPv6 Address Library

This is a simple library to parse, encode and match IP addresses.

IPv4 Class

IPv4 Getters

a-d: number

Gets the 1-4'th byte.

binary: number[]

Gets the bytes of the address.

cidr_range: number

Gets the possibly parsed CIDR range.

cidr: boolean

If the address is a CIDR range.

IPv4 Static Methods

decode(raw: string): IPv4Address

Parses the raw IPv4 address (possible CIDR Range) and returns the address.

IPv4 Methods

encode(): string

Encodes the current address (possible CIDR range) to an string.

cidr_match(cidr: IPv4Address): boolean

Checks if the current address is in the given range.

equals(other: IPv4Address): boolean

Checks if the current address quals the other.

IPv6 class

IPv6 Getters

cidr_range

Gets the CIDR range if there.

cidr

Checks if the address is a CIDR range.

pairs

Gets all the IPv6 Pairs (2-byte pairs)

bytes

Gets the bytes array of the address.

Binary

Gets the binary version of the address (128-bit bigint).

IPv6 Static Methods

decode(raw: string): IPv6Address

Decodes the given raw IPv6 address / CIDR range, and returns it as an address class.

IPv6 Method

encode(): string

Encodes the current address to a string.

cidr_match(cidr: IPv6Address): boolean

Checks if the current address is in the given CIDR range.

equals(other: IPv6Address): boolean

Checks if both addresses are equal.

Readme

Keywords

none

Package Sidebar

Install

npm i llibipaddress

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

22.6 kB

Total Files

10

Last publish

Collaborators

  • skywa04885