+6
-11
| "use strict"; | ||
| const cidrRegex = require("cidr-regex"); | ||
| const {v4, v6} = require("cidr-regex"); | ||
| const re4 = cidrRegex.v4({exact: true}); | ||
| const re6 = cidrRegex.v6({exact: true}); | ||
| const re4 = v4({exact: true}); | ||
| const re6 = v6({exact: true}); | ||
| const isCidr = module.exports = str => { | ||
| if (re4.test(str)) return 4; | ||
| if (re6.test(str)) return 6; | ||
| return 0; | ||
| }; | ||
| isCidr.v4 = str => re4.test(str); | ||
| isCidr.v6 = str => re6.test(str); | ||
| module.exports = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0); | ||
| module.exports.v4 = str => re4.test(str); | ||
| module.exports.v6 = str => re6.test(str); |
+5
-5
| { | ||
| "name": "is-cidr", | ||
| "version": "4.0.1", | ||
| "version": "4.0.2", | ||
| "description": "Check if a string is an IP address in CIDR notation", | ||
@@ -33,9 +33,9 @@ "author": "silverwind <me@silverwind.io>", | ||
| "dependencies": { | ||
| "cidr-regex": "^3.1.0" | ||
| "cidr-regex": "^3.1.1" | ||
| }, | ||
| "devDependencies": { | ||
| "eslint": "7.8.1", | ||
| "eslint-config-silverwind": "18.0.8", | ||
| "eslint": "7.10.0", | ||
| "eslint-config-silverwind": "18.0.10", | ||
| "jest": "26.4.2", | ||
| "updates": "10.3.6", | ||
| "updates": "11.1.5", | ||
| "versions": "8.4.3" | ||
@@ -42,0 +42,0 @@ }, |
4410
-1.19%35
-10.26%Updated