is-ip

5.0.1last stable release 1 year ago
Complexity Score
Low
Open Issues
1
Dependent Projects
155
Weekly Downloadsglobal
996,735

License

  • MIT
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

is-ip

Check if a string is an IP address

If you only need this for Node.js and don’t care about browser support, you may want to use net.isIP instead. Note that it returns an integer instead of a boolean.

Install

npm install is-ip

Usage

import {isIP, isIPv4} from 'is-ip';

isIP('1:2:3:4:5:6:7:8');
//=> true

isIP('192.168.0.1');
//=> true

isIPv4('1:2:3:4:5:6:7:8');
//=> false

API

isIP(string)

Check if string is IPv6 or IPv4.

isIPv6(string)

Check if string is IPv6.

isIPv4(string)

Check if string is IPv4.

ipVersion(string)

Returns 6 if string is IPv6, 4 if string is IPv4, or undefined if string is neither.

import {ipVersion} from 'is-ip';

ipVersion('1:2:3:4:5:6:7:8');
//=> 6

ipVersion('192.168.0.1');
//=> 4

ipVersion('abc');
//=> undefined

Related

  • ip-regex - Regular expression for matching IP addresses
  • is-cidr - Check if a string is an IP address in CIDR notation
  • cidr-regex - Regular expression for matching IP addresses in CIDR notation

Dependencies

CVE IssuesActive
0
Scorecards Score
4.20
Test Coverage
No Data
Follows Semver
Yes
Github Stars
112
Dependenciestotal
5
DependenciesOutdated
3
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute is-ip in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install is-ip
Processing...
Done

7 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.