cidrToRange() function
Expands a CIDR record into the first and last address it covers, as text.
Signature:
export declare function cidrToRange(cidr: string, type?: NetworkType, canonical?: boolean): [string, string];
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
cidr |
string |
a network in |
|
type |
(Optional) the family, if known; omit to have it detected | |
|
canonical |
boolean |
(Optional) for IPv6, render the expanded form instead of the compressed one |
Returns:
[string, string]
A [first, last] tuple of addresses, both ends inclusive.
Exceptions
TypeError or RangeError exactly as cidrToRangeInt() does — this is that function with intToIp() applied to each end.
Default Value
canonical defaults to false
Example
cidrToRange('10.0.0.0/8'); // ['10.0.0.0', '10.255.255.255']
cidrToRange('2001:db8::/32'); // ['2001:db8::', '2001:db8:ffff:...:ffff']
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.