Comparing version
16
index.js
'use strict'; | ||
var ipRegex = require('ip-regex'); | ||
const ipRegex = require('ip-regex'); | ||
var ip = module.exports = function (str) { | ||
return ipRegex({exact: true}).test(str); | ||
}; | ||
ip.v4 = function (str) { | ||
return ipRegex.v4({exact: true}).test(str); | ||
}; | ||
ip.v6 = function (str) { | ||
return ipRegex.v6({exact: true}).test(str); | ||
}; | ||
const isIp = module.exports = x => ipRegex({exact: true}).test(x); | ||
isIp.v4 = x => ipRegex.v4({exact: true}).test(x); | ||
isIp.v6 = x => ipRegex.v6({exact: true}).test(x); |
{ | ||
"name": "is-ip", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Check if a string is an IP address", | ||
@@ -10,9 +10,9 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -23,3 +23,5 @@ "files": [ | ||
"keywords": [ | ||
"text", | ||
"ip", | ||
"ipv6", | ||
"ipv4", | ||
"regex", | ||
@@ -31,4 +33,4 @@ "regexp", | ||
"find", | ||
"text", | ||
"pattern", | ||
"ip", | ||
"internet", | ||
@@ -38,2 +40,3 @@ "protocol", | ||
"validate", | ||
"detect", | ||
"check", | ||
@@ -44,7 +47,11 @@ "is", | ||
"dependencies": { | ||
"ip-regex": "^1.0.0" | ||
"ip-regex": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -8,3 +8,3 @@ # is-ip [](https://travis-ci.org/sindresorhus/is-ip) | ||
```sh | ||
``` | ||
$ npm install --save is-ip | ||
@@ -17,3 +17,3 @@ ``` | ||
```js | ||
var isIp = require('is-ip'); | ||
const isIp = require('is-ip'); | ||
@@ -33,17 +33,22 @@ isIp('192.168.0.1'); | ||
### isIp(string) | ||
### isIp(input) | ||
Check if a string is IPv4 or IPv6. | ||
Check if `input` is IPv4 or IPv6. | ||
### isIp.v4(string) | ||
### isIp.v4(input) | ||
Check if a string is IPv4. | ||
Check if `input` is IPv4. | ||
### isIp.v6(string) | ||
### isIp.v6(input) | ||
Check if a string is IPv6. | ||
Check if `input` is IPv6. | ||
## Related | ||
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2848
76.13%4
33.33%52
10.64%2
100%5
-54.55%1
Infinity%+ Added
- Removed
Updated