hard-cidr
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Hard CIDR

CIDR calculation functions to simplify complex network maps. Heavily influence by the functions available in Terraform. However, these only support IPv4. IPv6 might be supported later if there is sufficient demand.

install

npm i @sophosoft/hard-cidr

functions

cidrsubnet

Calculate a single subnet from a given CIDR range and additional bits, with an optional index.

import { cidrsubnet } from "@sophosoft/hard-cidr"
 
const subnet: string = cidrsubnet("172.16.0.0/12", 4, 2)
// 172.18.0.0/16

cidrsubnets

Calculate a sequence of non-overlapping, non-gapped subnets from a given CIDR range

import { cidrsubnets } from "@sophosoft/hard-cidr"
 
const subnets: string = cidrsubnets("10.1.0.0/16", [3, 4, 2, 2])
// [10.1.0.0/19, 10.1.32.0/23, 10.1.34.0/25, 10.1.34.128/25]

cidrhost

Calculate a single host ip from a given CIDR range

import { cidrhost } from "@sophosoft/hard-cidr"
 
const host: string = cidrhost("10.12.127.0/20", 16)
// 10.12.112.16

Package Sidebar

Install

npm i hard-cidr

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

6.2 kB

Total Files

5

Last publish

Collaborators

  • texdc