Ipv4Interval
const Ipv4Interval: BoundIntervalType<bigint> & object;Defined in: interval-ip.ts:125
Interval over IPv4 addresses (discrete, ε = one address). Values are the
address as a bigint: convert with .ip("10.0.0.1"), or build a whole
block with .cidr("10.0.0.0/8"). toString()/parse() use dotted form.
Type Declaration
Section titled “Type Declaration”| Name | Type | Description | Defined in |
|---|---|---|---|
cidr() |
(block) => Interval<bigint> |
The interval covering a CIDR block, e.g. "192.168.0.0/16" → [network, broadcast]. |
interval-ip.ts:69 |
ip() |
(addr) => bigint |
Parse a single address string to its comparable bigint value. |
interval-ip.ts:67 |
Example
Section titled “Example”import { Ipv4Interval } from "@xtandard/lib/ip";
const lan = Ipv4Interval.cidr("192.168.0.0/16");lan.contains(Ipv4Interval.ip("192.168.1.50")); // truelan.length(); // 65536lan.toString(); // "[192.168.0.0,192.168.255.255]"Ipv4Interval.cidr("10.0.0.0/24").difference(Ipv4Interval.cidr("10.0.0.64/26")).map(String);// ["[10.0.0.0,10.0.0.63]", "[10.0.0.128,10.0.0.255]"]