Get the minimum set of CIDR that covers every and only the input addresses or ranges.
Accepts IPv4 addresses in the following formats
- Single IP:
127.0.0.1
- IP range:
192.168.1.0-192.168.1.40
- CIDR:
192.168.1.0/27
$ cidr-coalesce 192.168.1.0-192.168.1.40
192.168.1.0/27
192.168.1.32/29
192.168.1.40/32
import coalesce from 'cidr-coalesce';
const result = coalesce(['192.168.1.0-192.168.1.40']);
// result = ['192.168.1.0/27', '192.168.1.32/29', '192.168.1.40/32']
Suppreses all error output.