• Home
Name Date Size #Lines LOC

..--

LICENSED12-May-20241.3 KiB2319

README.mdD12-May-20241.4 KiB5229

index.jsD12-May-2024325 1411

package.jsonD12-May-20241.8 KiB8180

README.md

1# is-cidr
2
3[![](https://img.shields.io/npm/v/is-cidr.svg?style=flat)](https://www.npmjs.org/package/is-cidr) [![](https://img.shields.io/npm/dm/is-cidr.svg)](https://www.npmjs.org/package/is-cidr) [![](https://api.travis-ci.org/silverwind/is-cidr.svg?style=flat)](https://travis-ci.org/silverwind/is-cidr)
4
5> Check if a string is an IP address in CIDR notation
6
7## Install
8
9```
10npm i is-cidr
11```
12
13
14## Usage
15
16```js
17const isCidr = require('is-cidr');
18
19isCidr('192.168.0.1/24'); //=> 4
20isCidr('1:2:3:4:5:6:7:8/64'); //=> 6
21isCidr('10.0.0.0'); //=> 0
22isCidr.v6('10.0.0.0/24'); //=> false
23```
24
25
26## API
27
28### isCidr(input)
29
30Check if `input` is a IPv4 or IPv6 CIDR address. Returns either `4`, `6` (indicating the IP version) or `0` if the string is not a CIDR.
31
32### isCidr.v4(input)
33
34Check if `input` is a IPv4 CIDR address. Returns a boolean.
35
36### isCidr.v6(input)
37
38Check if `input` is a IPv6 CIDR address. Returns a boolean.
39
40
41## Related
42
43- [cidr-regex](https://github.com/silverwind/cidr-regex) - Regular expression for matching IP addresses in CIDR notation
44- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
45- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
46
47## License
48
49© [silverwind](https://github.com/silverwind), distributed under BSD licence
50
51Based on previous work by [Felipe Apostol](https://github.com/flipjs)
52