Socket
Socket
Sign inDemoInstall

is-ip

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-ip - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

19

index.d.ts

@@ -43,4 +43,23 @@ declare const isIp: {

v6(string: string): boolean;
/**
@returns `6` if `string` is IPv6, `4` if `string` is IPv4, or `undefined` if `string` is neither.
@example
```
import isIp = require('is-ip');
isIp.version('192.168.0.1');
//=> 4
isIp.version('1:2:3:4:5:6:7:8');
//=> 6
isIp.version('abc');
//=> undefined
```
*/
version(string: string): 4 | 6 | undefined;
};
export = isIp;

1

index.js

@@ -7,3 +7,4 @@ 'use strict';

isIp.v6 = string => ipRegex.v6({exact: true}).test(string);
isIp.version = string => isIp(string) ? (isIp.v4(string) ? 4 : 6) : undefined;
module.exports = isIp;

2

package.json
{
"name": "is-ip",
"version": "3.0.0",
"version": "3.1.0",
"description": "Check if a string is an IP address",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -43,3 +43,18 @@ # is-ip [![Build Status](https://travis-ci.org/sindresorhus/is-ip.svg?branch=master)](https://travis-ci.org/sindresorhus/is-ip)

### isIp.version(string)
Returns `6` if `string` is IPv6, `4` if `string` is IPv4, or `undefined` if `string` is neither.
```js
isIp.version('192.168.0.1');
//=> 4
isIp.version('1:2:3:4:5:6:7:8');
//=> 6
isIp.version('abc');
//=> undefined
```
## Related

@@ -46,0 +61,0 @@

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