Networks class
A CIDR membership set covering both address families — the entry point for most callers.
Signature:
export declare class Networks
Remarks
Give it a mixed list of CIDR records and it sorts them into one NetworkList per family, then dispatches each lookup to the list matching the address it is asked about. That indirection exists because the two families cannot share a buffer: an IPv6 record is 32 bytes against IPv4's 8.
Lookups are O(log n) within a family. Instances are immutable, so extending a set means constructing a new one.
A family with no networks is left unset rather than empty, and Networks.includes() answers false for it — so a v4-only set safely answers questions about IPv6 addresses.
Example
const allowed = new Networks(['10.0.0.0/8', '2001:db8::/32']);
allowed.includes('10.1.2.3'); // true
allowed.includes('2001:db8::1'); // true
allowed.includes('8.8.8.8'); // false
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Builds a set from CIDR records of either family, or from previously packed buffers. |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
|
The IPv4 networks, as a NetworkList — reachable as | ||
|
|
The IPv6 networks, as a NetworkList — reachable as |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Whether an address falls inside any network in this set. | ||
|
Every stored network as CIDR records, IPv4 first. | ||
|
Every stored range as integer pairs, grouped by family. | ||
|
The CIDR array, so |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.