Socket
Socket
Sign inDemoInstall

is-ip

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-ip

Check if a string is an IP address


Version published
Maintainers
1
Install size
13.6 kB
Created

Readme

Source

is-ip Build Status

Check if a string is an IP address

Install

$ npm install is-ip

Usage

const isIp = require('is-ip');

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

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

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

API

isIp(string)

Check if string is IPv4 or IPv6.

isIp.v4(string)

Check if string is IPv4.

isIp.v6(string)

Check if string is IPv6.

isIp.version(string)

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

isIp.version('192.168.0.1');
//=> 4

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

isIp.version('abc');
//=> undefined
  • 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

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 19 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc