cidr-regex 4.0.3 → 4.0.5

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.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/index.d.ts +29 -35
  3. package/package.json +8 -7
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # cidr-regex
2
- [![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex)
2
+ [![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex) [![](https://packagephobia.com/badge?p=cidr-regex)](https://packagephobia.com/result?p=cidr-regex)
3
3
 
4
4
  > Regular expression for matching IP addresses in CIDR notation
5
5
 
@@ -50,9 +50,10 @@ Only match an exact string. Useful with `RegExp#test()` to check if a string is
50
50
 
51
51
  ## Related
52
52
 
53
+ - [ip-bigint](https://github.com/silverwind/ip-bigint) - Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
54
+ - [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
53
55
  - [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation
54
56
  - [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
55
- - [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses
56
57
  - [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists
57
58
 
58
59
  ## License
package/index.d.ts CHANGED
@@ -1,24 +1,31 @@
1
- declare namespace ip {
2
- interface Options {
3
- /**
4
- Only match an exact string. Useful with `RegExp#test()` to check if a string is a CIDR IP address. *(`false` matches any CIDR IP address in a string)*
5
-
6
- @default false
7
- */
8
- readonly exact?: boolean;
9
- }
1
+ export type Options = {
2
+ /**
3
+ Only match an exact string. Useful with `RegExp#test()` to check if a string is an IP address. *(`false` matches any IP address in a string)*
4
+
5
+ @default false
6
+ */
7
+ readonly exact?: boolean;
10
8
  }
11
9
 
12
- declare const ip: {
10
+ /**
11
+ @returns A regex for matching IPv4 CIDRs.
12
+ */
13
+ export function v4(options?: Options): RegExp;
14
+
15
+ /**
16
+ @returns A regex for matching IPv6 CIDRs.
17
+ */
18
+ export function v6(options?: Options): RegExp;
19
+
20
+ declare const _default: {
21
+
13
22
  /**
14
- Regular expression for matching IP addresses in CIDR notation.
23
+ Regular expression for matching IP addresses in CIDR notation
15
24
 
16
- @returns A regex for matching both IPv4 and IPv6 CIDR IP addresses.
25
+ @returns A regex for matching both IPv4 and IPv6 CIDRs.
17
26
 
18
27
  @example
19
28
  ```
20
- import cidrRegex = require("cidr-regex");
21
-
22
29
  // Contains a CIDR IP address?
23
30
  cidrRegex().test("foo 192.168.0.1/24");
24
31
  //=> true
@@ -27,29 +34,16 @@ declare const ip: {
27
34
  cidrRegex({exact: true}).test("foo 192.168.0.1/24");
28
35
  //=> false
29
36
 
30
- "foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz".match(cidrRegex());
31
- //=> ["192.168.0.1/24", "1:2:3:4:5:6:7:8/64"]
32
- ```
33
- */
34
- (options?: ip.Options): RegExp;
35
-
36
- /**
37
- @returns A regex for matching IPv4 CIDR IP addresses.
38
- */
39
- v4(options?: ip.Options): RegExp;
40
-
41
- /**
42
- @returns A regex for matching IPv6 CIDR IP addresses.
43
-
44
- @example
45
- ```
46
- import cidrRegex = require("cidr-regex");
47
-
48
37
  cidrRegex.v6({exact: true}).test("1:2:3:4:5:6:7:8/64");
49
38
  //=> true
39
+
40
+ // Extract CIDRs from string
41
+ "foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz".match(cidrRegex());
42
+ //=> ["192.168.0.1/24", "1:2:3:4:5:6:7:8/64"]
50
43
  ```
51
44
  */
52
- v6(options?: ip.Options): RegExp;
45
+ (options?: Options): RegExp,
46
+ v4: typeof v4;
47
+ v6: typeof v6;
53
48
  };
54
-
55
- export = ip;
49
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidr-regex",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "Regular expression for matching IP addresses in CIDR notation",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "contributors": [
@@ -22,11 +22,12 @@
22
22
  "ip-regex": "^5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "eslint": "8.37.0",
26
- "eslint-config-silverwind": "65.1.3",
27
- "tsd": "0.28.1",
28
- "updates": "13.2.9",
29
- "versions": "10.4.2",
30
- "vitest": "0.29.8"
25
+ "eslint": "8.57.0",
26
+ "eslint-config-silverwind": "83.0.1",
27
+ "tsd": "0.31.0",
28
+ "updates": "16.0.0",
29
+ "versions": "12.0.1",
30
+ "vitest": "1.4.0",
31
+ "vitest-config-silverwind": "7.0.3"
31
32
  }
32
33
  }