@common.js/is-ip 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +18 -4
- package/package.json +14 -5
- package/readme.md +0 -63
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
The [is-ip](https://www.npmjs.com/package/is-ip) package exported as CommonJS modules.
|
|
4
4
|
|
|
5
|
-
Exported from [is-ip@5.0.
|
|
5
|
+
Exported from [is-ip@5.0.1](https://www.npmjs.com/package/is-ip/v/5.0.1) using https://github.com/etienne-martin/common.js.
|
package/index.js
CHANGED
|
@@ -35,20 +35,34 @@ var options = {
|
|
|
35
35
|
timeout: 400
|
|
36
36
|
};
|
|
37
37
|
function isIP(string) {
|
|
38
|
+
if (string.length > maxIPv6Length) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
38
41
|
return (0, _superRegex.isMatch)((0, _ipRegex.default)({
|
|
39
42
|
exact: true
|
|
40
|
-
}), string
|
|
43
|
+
}), string, options);
|
|
41
44
|
}
|
|
42
45
|
function isIPv6(string) {
|
|
46
|
+
if (string.length > maxIPv6Length) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
43
49
|
return (0, _superRegex.isMatch)(_ipRegex.default.v6({
|
|
44
50
|
exact: true
|
|
45
|
-
}), string
|
|
51
|
+
}), string, options);
|
|
46
52
|
}
|
|
47
53
|
function isIPv4(string) {
|
|
54
|
+
if (string.length > maxIPv4Length) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
48
57
|
return (0, _superRegex.isMatch)(_ipRegex.default.v4({
|
|
49
58
|
exact: true
|
|
50
|
-
}), string
|
|
59
|
+
}), string, options);
|
|
51
60
|
}
|
|
52
61
|
function ipVersion(string) {
|
|
53
|
-
|
|
62
|
+
if (isIPv6(string)) {
|
|
63
|
+
return 6;
|
|
64
|
+
}
|
|
65
|
+
if (isIPv4(string)) {
|
|
66
|
+
return 4;
|
|
67
|
+
}
|
|
54
68
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common.js/is-ip",
|
|
3
|
-
"version": "5.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
|
+
"description": "is-ip package exported as CommonJS modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "etienne-martin/common.js",
|
|
7
7
|
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
8
|
"type": "commonjs",
|
|
9
|
+
"exports": "./index.js",
|
|
9
10
|
"types": "./index.d.ts",
|
|
10
11
|
"engines": {
|
|
11
12
|
"node": ">=14.16"
|
|
@@ -18,14 +19,22 @@
|
|
|
18
19
|
"index.d.ts"
|
|
19
20
|
],
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"ip-regex": "npm:@common.js/ip-regex@5.0.1",
|
|
23
|
+
"super-regex": "npm:@common.js/super-regex@0.2.1"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"ava": "^4.3.1",
|
|
26
27
|
"tsd": "^0.22.0",
|
|
27
|
-
"xo": "^0.
|
|
28
|
+
"xo": "^0.54.0"
|
|
28
29
|
},
|
|
29
30
|
"homepage": "https://github.com/etienne-martin/common.js#readme",
|
|
31
|
+
"commonjs": {
|
|
32
|
+
"source": {
|
|
33
|
+
"name": "is-ip",
|
|
34
|
+
"version": "5.0.1"
|
|
35
|
+
},
|
|
36
|
+
"transformRevision": 1,
|
|
37
|
+
"buildKey": "2438e683a74e5258b3176f6dd22c805cc75d3836d1612ba1577b67da8c36dddc"
|
|
38
|
+
},
|
|
30
39
|
"main": "./index.js"
|
|
31
40
|
}
|
package/readme.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# is-ip
|
|
2
|
-
|
|
3
|
-
> Check if a string is an IP address
|
|
4
|
-
|
|
5
|
-
If you only need this for Node.js and don't care about browser support, you may want to use [`net.isIP`](https://nodejs.org/api/net.html#net_net_isip_input) instead. Note that it returns an integer instead of a boolean.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npm install is-ip
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import {isIP, isIPv4} from 'is-ip';
|
|
17
|
-
|
|
18
|
-
isIP('1:2:3:4:5:6:7:8');
|
|
19
|
-
//=> true
|
|
20
|
-
|
|
21
|
-
isIP('192.168.0.1');
|
|
22
|
-
//=> true
|
|
23
|
-
|
|
24
|
-
isIPv4('1:2:3:4:5:6:7:8');
|
|
25
|
-
//=> false
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## API
|
|
29
|
-
|
|
30
|
-
### isIP(string)
|
|
31
|
-
|
|
32
|
-
Check if `string` is IPv6 or IPv4.
|
|
33
|
-
|
|
34
|
-
### isIPv6(string)
|
|
35
|
-
|
|
36
|
-
Check if `string` is IPv6.
|
|
37
|
-
|
|
38
|
-
### isIPv4(string)
|
|
39
|
-
|
|
40
|
-
Check if `string` is IPv4.
|
|
41
|
-
|
|
42
|
-
### ipVersion(string)
|
|
43
|
-
|
|
44
|
-
Returns `6` if `string` is IPv6, `4` if `string` is IPv4, or `undefined` if `string` is neither.
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import {ipVersion} from 'is-ip';
|
|
48
|
-
|
|
49
|
-
ipVersion('1:2:3:4:5:6:7:8');
|
|
50
|
-
//=> 6
|
|
51
|
-
|
|
52
|
-
ipVersion('192.168.0.1');
|
|
53
|
-
//=> 4
|
|
54
|
-
|
|
55
|
-
ipVersion('abc');
|
|
56
|
-
//=> undefined
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Related
|
|
60
|
-
|
|
61
|
-
- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
|
|
62
|
-
- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation
|
|
63
|
-
- [cidr-regex](https://github.com/silverwind/cidr-regex) - Regular expression for matching IP addresses in CIDR notation
|