cidr-block
Advanced tools
| import { Ipv6Literal, Ipv6Representable } from './types'; | ||
| export declare class Ipv6Address { | ||
| private _address; | ||
| constructor(address: Ipv6Literal); | ||
| get address(): bigint; | ||
| toString(): string; | ||
| equals(otherIpAddress: Ipv6Representable): boolean; | ||
| nextIp(): Ipv6Address; | ||
| previousIp(): Ipv6Address; | ||
| } | ||
| export declare function address(ip: Ipv6Literal): Ipv6Address; | ||
| export declare function stringToNum(address: string): bigint; | ||
| export declare function numToString(num: bigint): string; |
| import { Ipv6Address } from './ipv6-address'; | ||
| /** | ||
| * Type that indicates a literal string or number value that represents an IPv6 address | ||
| */ | ||
| export declare type Ipv6Literal = string | bigint; | ||
| /** | ||
| * Type that indicates either a literal value or an address instance that is an IPv6 | ||
| */ | ||
| export declare type Ipv6Representable = Ipv6Address | Ipv6Literal; |
@@ -7,3 +7,3 @@ import { Ipv4Literal, Ipv4Representable } from './types'; | ||
| * @remarks | ||
| * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead. | ||
| * Direct instantiation should be avoided; use {@link ipv4.address} instead. | ||
| */ | ||
@@ -22,4 +22,4 @@ export declare class Ipv4Address { | ||
| * | ||
| * ip.address(255n) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0' | ||
| * ip.address(255) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0' | ||
| * ```` | ||
@@ -107,4 +107,4 @@ * | ||
| * | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true | ||
| * ``` | ||
@@ -128,5 +128,5 @@ * | ||
| * | ||
| * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true | ||
| * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true | ||
| * ``` | ||
@@ -133,0 +133,0 @@ * |
@@ -19,3 +19,3 @@ class InvalidIpAddressError extends Error { | ||
| * @remarks | ||
| * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead. | ||
| * Direct instantiation should be avoided; use {@link ipv4.address} instead. | ||
| */ | ||
@@ -38,4 +38,4 @@ class Ipv4Address { | ||
| * | ||
| * ip.address(255n) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0' | ||
| * ip.address(255) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0' | ||
| * ```` | ||
@@ -138,4 +138,4 @@ * | ||
| * | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true | ||
| * ``` | ||
@@ -177,5 +177,5 @@ * | ||
| * | ||
| * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true | ||
| * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true | ||
| * ``` | ||
@@ -182,0 +182,0 @@ * |
+8
-8
@@ -19,3 +19,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});class InvalidIpAddressError extends Error { | ||
| * @remarks | ||
| * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead. | ||
| * Direct instantiation should be avoided; use {@link ipv4.address} instead. | ||
| */ | ||
@@ -38,4 +38,4 @@ class Ipv4Address { | ||
| * | ||
| * ip.address(255n) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0' | ||
| * ip.address(255) // ==> '0.0.0.255' | ||
| * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0' | ||
| * ```` | ||
@@ -138,4 +138,4 @@ * | ||
| * | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true | ||
| * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true | ||
| * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true | ||
| * ``` | ||
@@ -177,5 +177,5 @@ * | ||
| * | ||
| * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true | ||
| * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true | ||
| * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true | ||
| * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true | ||
| * ``` | ||
@@ -182,0 +182,0 @@ * |
+1
-1
| { | ||
| "name": "cidr-block", | ||
| "description": "ipv4 and ipv6 address and cidr range utilities", | ||
| "version": "1.2.0", | ||
| "version": "1.3.0", | ||
| "license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Brandon Burrus <brandon@burrus.io>", |
40611
2.04%18
12.5%870
2.59%