Comparing version 3.0.0 to 3.1.0
@@ -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; |
@@ -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; |
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4255
56
69