1.0.5 • Published 4 years ago

@eryldor/cidr v1.0.5

Weekly downloads
9
License
MPL-2.0
Repository
gitlab
Last release
4 years ago

cidr

cidr is a typescript library that helps to manipulate CIDR blocks.

Click here to access the documentation

Usage

import { CIDRBlock } from "@eryldor/cidr";

const cidr = CIDRBlock.fromString("10.0.0.0/16");

//Print "10.0.0.0"
console.log(cidr.networkAddress);
//Print "16"
console.log(cidr.networkPrefix);
//Print "10.0.255.255"
console.log(cidr.broadcastAddress)

//Let's divide it into 2 subnets
const subnets = cidr.split(2);
//Print "10.0.0.0/17"
console.log(subnets[0].toString());
//Print "10.0.128.0/17"
console.log(subnets[1].toString());

//Enumerate all the IPs except the network and broadcast address.
for(ip of cidr.ipAddress()) {
    console.log(ip);
}
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago