1.0.5 • Published 6 years ago

@eryldor/cidr v1.0.5

Weekly downloads
9
License
MPL-2.0
Repository
gitlab
Last release
6 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

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago