Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-cidr

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-cidr - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

index.js

75

package.json
{
"name": "is-cidr",
"version": "1.0.0",
"description": "Check if a string is a valid CIDR",
"main": "lib/index.js",
"version": "2.0.0",
"description": "Check if a string is an IP address in CIDR notation",
"author": "silverwind <me@silverwind.io>",
"contributors": [
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
],
"repository": "silverwind/is-cidr",
"license": "BSD-2-Clause",
"scripts": {
"commit": "git-cz",
"prebuild": "npm run lint && npm run clean",
"build": "babel --presets es2015 -d lib/ src/",
"clean": "rimraf lib && mkdir lib",
"lint": "eslint src/ test/",
"test": "ava --require babel-register",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/flipjs/is-cidr.git"
},
"files": [
"index.js"
],
"keywords": [
"cidr",
"regex",
"notation",
"cidr notation",
"prefix",
"prefixes",
"ip",
"ip address",
"cidr",
"netblock",
"regex"
"ip address"
],
"author": "Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/flipjs/is-cidr/issues"
},
"homepage": "https://github.com/flipjs/is-cidr#readme",
"devDependencies": {
"ava": "0.13.0",
"babel-cli": "6.6.5",
"babel-preset-es2015": "6.6.0",
"babel-register": "6.7.2",
"commitizen": "2.7.3",
"cz-conventional-changelog": "1.1.5",
"eslint": "2.4.0",
"eslint-config-standard": "5.1.0",
"eslint-plugin-babel": "3.1.0",
"eslint-plugin-promise": "1.1.0",
"eslint-plugin-standard": "1.3.2",
"ghooks": "1.0.3",
"rimraf": "2.5.2",
"semantic-release": "4.3.5"
"ava": "^0.24.0",
"eslint": "^4.13.0",
"updates": "^2.0.3"
},
"babel": {
"presets": [
"es2015"
]
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
},
"ghooks": {
"pre-commit": "npm run test && npm run build"
}
},
"dependencies": {
"cidr-regex": "1.0.6"
"cidr-regex": "^2.0.1"
}
}
# is-cidr
Check if a string is a valid CIDR
[![](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)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![version](https://img.shields.io/npm/v/is-cidr.svg?style=flat-square)](http://npm.im/is-cidr)
[![MIT License](https://img.shields.io/npm/l/is-cidr.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![travis build](https://img.shields.io/travis/flipjs/is-cidr.svg?style=flat-square)](https://travis-ci.org/flipjs/is-cidr)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![downloads](https://img.shields.io/npm/dm/is-cidr.svg?style=flat-square)](http://npm-stat.com/charts.html?package=is-cidr&from=2016-03-24)
> Check if a string is an IP address in CIDR notation
## Install
```sh
```
$ npm install --save is-cidr
```
## Usage
```js
import isCidr from 'is-cidr' // default is isCidrV4
import { isCidrV4, isCidrV6 } from 'is-cidr'
// OR
var isCidrV4 = require('is-cidr').isCidrV4
var isCidrV6 = require('is-cidr').isCidrV6
const isCidr = require('is-cidr');
// is a CIDR v4
isCidr('18.101.25.153/24') // true
isCidr('192.168.0.1/24');
//=> true
// is not a CIDR v4
isCidrV4('999.999.999.999/12') // false
isCidr('1:2:3:4:5:6:7:8/64');
//=> true
// is a CIDR v6
isCidrV6('fe80:0000:0000:0000:0204:61ff:fe9d:f156') // true
// is not a CIDR v6
isCidrV6('fe80:0000:0000:0000:0204:61ff:fe9d:f156/a') // false
isCidr.v4('1:2:3:4:5:6:7:8/64');
//=> false
```
## API
### isCidr(string)
### isCidr(input)
Check if a string is CIDR IPv4.
Check if `input` is a IPv4 or IPv6 CIDR address.
### isCidrV4(string)
### isCidr.v4(input)
Check if a string is CIDR IPv4.
Check if `input` is IPv4 CIDR address.
### isCidrV6(string)
### isCidr.v6(input)
Check if a string is CIDR IPv6.
Check if `input` is IPv6 CIDR address.
## Related
- [cidr-regex](https://github.com/silverwind/cidr-regex) - Regular expression for matching IP addresses in CIDR notation
- [is-cidr](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
## License
MIT © [Felipe Apostol](https://github.com/flipjs)
© [silverwind](https://github.com/silverwind), distributed under BSD licence
Based on previous work by [Felipe Apostol](https://github.com/flipjs)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc