# NetworkList.(constructor) · @imqueue/net

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

Builds a list from CIDR records, or adopts an already-packed buffer.

**Signature:**

```typescript
constructor(networks: string[] | Buffer, type?: NetworkType);
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| networks | string\[\] \| Buffer | CIDR records, each with an explicit `/prefix`; or a buffer previously taken from [NetworkList.networks](https://imqueue.org/api/net/latest/net.networklist.networks/) |
| type | [NetworkType](https://imqueue.org/api/net/latest/net.networktype/) | _(Optional)_ the address family. Optional only for the array form, where it is detected from the first record; required for the buffer form, since the bytes do not say. |


## Exceptions

TypeError if a record's address is invalid, if the records disagree on family, or — for the buffer form — if `type` was omitted or the buffer is empty or not a whole number of records.

RangeError if a record has no `/prefix`. A bare address is rejected, so a single host is `10.0.0.1/32`.

## Remarks

The array form sorts and deduplicates by range, so the resulting [NetworkList.length](https://imqueue.org/api/net/latest/net.networklist.length/) may be lower than the number of records you passed. The buffer form trusts the bytes and copies nothing — it keeps a reference, so mutating that buffer afterwards corrupts the list.

## Example


```typescript
const list = new NetworkList(['10.0.0.0/8', '192.168.0.0/16']);

// Cheap round trip: keep the bytes, restate the family.
const same = new NetworkList(list.networks, list.type);
```

