Skip to content

Commit

Permalink
add info regarding expandCidr to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jul 25, 2024
1 parent c26e235 commit 74c8783
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ Returns an array of merged remaining networks.

- `networks` *String* or *Array*: One or more CIDR or IP addresses.

Returns a generator for individual IPs contained in the networks. Be aware that asking for expansions of big networks can result in long runtimes and possibly high memory usage. One million IPs takes about 2 seconds on modern hardware.
Returns a generator for individual IPs contained in the networks.

Be aware that passing large networks that contain millions of IPs can result in memory exhaustion and slow execution time. It's recommended to validate the amount of IPs first, for example, like this:

```js
const {start, end} = parseCidr(net);
if (end - start >= 1000000n) {
throw new Error("Too many IPs");
}
``

### overlapCidr(networksA, networksB)

Expand Down

0 comments on commit 74c8783

Please sign in to comment.