ip-bigint
Advanced tools
Comparing version 6.0.1 to 7.0.0
export const max4 = 2n ** 32n - 1n; | ||
export const max6 = 2n ** 128n - 1n; | ||
const emptyPartsRe = /\b:?(?:0+:?){2,}/; | ||
const emptyPartsRe = /\b:?(?:0+:?)+/; | ||
const isIP = ip => ip.includes(":") ? 6 : ip.includes(".") ? 4 : 0; | ||
@@ -103,1 +103,5 @@ | ||
} | ||
export function normalizeIp(ip) { | ||
return stringifyIp(parseIp(ip)); | ||
} |
{ | ||
"name": "ip-bigint", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "Convert IPv4 and IPv6 addresses to native BigInt and vice-versa", | ||
@@ -15,11 +15,11 @@ "author": "silverwind <me@silverwind.io>", | ||
"files": [ | ||
"index.js" | ||
"./index.js" | ||
], | ||
"devDependencies": { | ||
"eslint": "8.39.0", | ||
"eslint-config-silverwind": "66.0.0", | ||
"updates": "14.1.0", | ||
"versions": "11.0.0", | ||
"vitest": "0.30.1" | ||
"eslint": "8.41.0", | ||
"eslint-config-silverwind": "73.0.0", | ||
"updates": "14.1.1", | ||
"versions": "11.0.1", | ||
"vitest": "0.31.2" | ||
} | ||
} |
@@ -6,17 +6,16 @@ # ip-bigint | ||
## Install | ||
## Usage | ||
``` | ||
npm i ip-bigint | ||
``` | ||
## Example | ||
```js | ||
import {parseIp, stringifyIp} from "ip-bigint"; | ||
import {parseIp, stringifyIp, normalizeIp} from "ip-bigint"; | ||
const {number, version} = parseIp("2001:db8::"); | ||
parseIp("2001:db8::"); | ||
// => {number: 42540766411282592856903984951653826560n, version: 6} | ||
const ip = stringifyIp({number, version}); | ||
stringifyIp({number, version}); | ||
// => "2001:db8::" | ||
normalizeIp("2001:db8::0:0:1") | ||
// => "2001:db8::1" | ||
``` | ||
@@ -39,2 +38,6 @@ | ||
### normalizeIp(ip) | ||
Round-trip an IP address through `parseIp` and `stringifyIp`, effectively normalizing its representation. | ||
### Constants | ||
@@ -41,0 +44,0 @@ |
4876
90
48