# NetworkList class · @imqueue/net

Source: https://imqueue.org/api/net/latest/net.networklist/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/net 3.0.2 — generated reference, not hand-written

A single-family list of networks, stored as sorted binary ranges and searched in O(log n).

**Signature:**

```typescript
export declare class NetworkList 
```

## Remarks

One family per list — the record widths differ, so IPv4 and IPv6 cannot share a buffer. Reach for [Networks](https://imqueue.org/api/net/latest/net.networks/) unless you know the family up front; it holds one of these per family and dispatches on the address it is given.

Each network is one record of two addresses, start and end: 8 bytes for IPv4 and 32 for IPv6, so memory is linear in the number of networks and independent of how large each network is. Records are sorted at construction, which is what makes the binary search in [NetworkList.includes()](https://imqueue.org/api/net/latest/net.networklist.includes/) valid.

Instances are effectively immutable — every field is `readonly` and there is no method that adds or removes a network. Extending a list means constructing a new one.

`JSON.stringify` produces the CIDR array via [NetworkList.toJSON()](https://imqueue.org/api/net/latest/net.networklist.tojson/), and that array can be passed straight back to the constructor. Passing the raw [NetworkList.networks](https://imqueue.org/api/net/latest/net.networklist.networks/) buffer works too, and is cheaper, but then the family must be supplied explicitly because the bytes do not record it.

## Constructors


| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(networks, type)](https://imqueue.org/api/net/latest/net.networklist._constructor_/) |  | Builds a list from CIDR records, or adopts an already-packed buffer. |


## Properties


| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [addressSize](https://imqueue.org/api/net/latest/net.networklist.addresssize/) | `readonly` | number | Bytes per address: 4 for IPv4, 16 for IPv6, per [sizeOf()](https://imqueue.org/api/net/latest/net.sizeof/). |
| [bytesLength](https://imqueue.org/api/net/latest/net.networklist.byteslength/) | `readonly` | number | Size of [NetworkList.networks](https://imqueue.org/api/net/latest/net.networklist.networks/) in bytes. |
| [length](https://imqueue.org/api/net/latest/net.networklist.length/) | `readonly` | number | How many networks the list holds. |
| [networks](https://imqueue.org/api/net/latest/net.networklist.networks/) | `readonly` | Buffer | The packed records: `[start, end]` address pairs, little-endian, ascending. |
| [recordSize](https://imqueue.org/api/net/latest/net.networklist.recordsize/) | `readonly` | number | Bytes per record: two addresses, so 8 for IPv4 and 32 for IPv6. |
| [type](https://imqueue.org/api/net/latest/net.networklist.type/) | `readonly` | [NetworkType](https://imqueue.org/api/net/latest/net.networktype/) | The address family every record in this list belongs to. |


## Methods


| Method | Modifiers | Description |
| --- | --- | --- |
| [includes(ip)](https://imqueue.org/api/net/latest/net.networklist.includes/) |  | Whether an address falls inside any network in this list. |
| [toArray(canonical)](https://imqueue.org/api/net/latest/net.networklist.toarray/) |  | The stored networks as CIDR records. |
| [toIntArray()](https://imqueue.org/api/net/latest/net.networklist.tointarray/) |  | The stored ranges as integer pairs. |
| [toJSON()](https://imqueue.org/api/net/latest/net.networklist.tojson/) |  | The CIDR array, so `JSON.stringify` on this object yields the network list. |

