Socket
Socket
Sign inDemoInstall

is-ip

Package Overview
Dependencies
7
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
Weekly downloads
812K
decreased by-12.77%
Maintainers
1
Install size
42.7 kB
Created
Weekly downloads
 

Readme

Source

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
  • 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

Keywords

FAQs

Last updated on 05 Aug 2023

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