ip-bigint
Advanced tools
Comparing version 7.2.1 to 7.3.0
@@ -5,3 +5,3 @@ export const max4 = 2n ** 32n - 1n; | ||
export function parseIp(ip) { | ||
const version = ip.includes(":") ? 6 : ip.includes(".") ? 4 : 0; | ||
const version = ipVersion(ip); | ||
if (!version) throw new Error(`Invalid IP address: ${ip}`); | ||
@@ -141,1 +141,5 @@ | ||
} | ||
export function ipVersion(ip) { | ||
return ip.includes(":") ? 6 : ip.includes(".") ? 4 : 0; | ||
} |
{ | ||
"name": "ip-bigint", | ||
"version": "7.2.1", | ||
"version": "7.3.0", | ||
"description": "Convert IPv4 and IPv6 addresses to native BigInt and vice-versa", | ||
@@ -18,8 +18,9 @@ "author": "silverwind <me@silverwind.io>", | ||
"devDependencies": { | ||
"eslint": "8.41.0", | ||
"eslint-config-silverwind": "73.0.0", | ||
"updates": "14.1.1", | ||
"eslint": "8.45.0", | ||
"eslint-config-silverwind": "74.0.0", | ||
"updates": "14.3.4", | ||
"versions": "11.0.1", | ||
"vitest": "0.31.2" | ||
"vitest": "0.33.0", | ||
"vitest-config-silverwind": "2.1.0" | ||
} | ||
} |
# ip-bigint | ||
[![](https://img.shields.io/npm/v/ip-bigint.svg?style=flat)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/npm/dm/ip-bigint.svg)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/bundlephobia/minzip/ip-bigint.svg)](https://bundlephobia.com/package/ip-bigint) | ||
[![](https://img.shields.io/npm/v/ip-bigint.svg?style=flat)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/npm/dm/ip-bigint.svg)](https://www.npmjs.org/package/ip-bigint) [![](https://img.shields.io/bundlephobia/minzip/ip-bigint.svg)](https://bundlephobia.com/package/ip-bigint) [![](https://packagephobia.com/badge?p=ip-bigint)](https://packagephobia.com/result?p=ip-bigint) | ||
> Tools to work with IPv4 and IPv6 CIDR | ||
@@ -57,4 +58,8 @@ > Convert IPv4 and IPv6 addresses to native BigInt and vice-versa | ||
### ipVersion(ip) | ||
Returns a integer of the IP version, 4, 6 or 0 if it's not an IP. Very rudimentary and should not be used for validation. | ||
## License | ||
© [silverwind](https://github.com/silverwind), distributed under BSD licence |
6575
124
65
6