Socket
Socket
Sign inDemoInstall

ip-bigint

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.3.0 to 8.0.0

22

index.js
export const max4 = 2n ** 32n - 1n;
export const max6 = 2n ** 128n - 1n;
export function ipVersion(ip) {
return ip.includes(":") ? 6 : ip.includes(".") ? 4 : 0;
}
export function parseIp(ip) {

@@ -57,6 +61,2 @@ const version = ipVersion(ip);

export function stringifyIp({number, version, ipv4mapped, scopeid} = {}, {compress = true, hexify = false} = {}) {
if (typeof number !== "bigint") throw new Error(`Expected a BigInt`);
if (![4, 6].includes(version)) throw new Error(`Invalid version: ${version}`);
if (number < 0n || number > (version === 4 ? max4 : max6)) throw new Error(`Invalid number: ${number}`);
let step = version === 4 ? 24n : 112n;

@@ -98,7 +98,3 @@ const stepReduction = version === 4 ? 8n : 16n;

if (scopeid) {
ip = `${ip}%${scopeid}`;
}
return ip;
return scopeid ? `${ip}%${scopeid}` : ip;
}

@@ -123,6 +119,4 @@ }

if (current) {
if (!longest) {
if (!longest || current.size > longest.size) {
longest = current;
} else if (current.size > longest.size) {
longest = current;
}

@@ -143,5 +137,1 @@ current = null;

}
export function ipVersion(ip) {
return ip.includes(":") ? 6 : ip.includes(".") ? 4 : 0;
}
{
"name": "ip-bigint",
"version": "7.3.0",
"version": "8.0.0",
"description": "Convert IPv4 and IPv6 addresses to native BigInt and vice-versa",

@@ -12,3 +12,3 @@ "author": "silverwind <me@silverwind.io>",

"engines": {
"node": ">=16"
"node": ">=18"
},

@@ -19,9 +19,9 @@ "files": [

"devDependencies": {
"eslint": "8.45.0",
"eslint-config-silverwind": "74.0.0",
"updates": "14.3.4",
"versions": "11.0.1",
"vitest": "0.33.0",
"vitest-config-silverwind": "2.1.0"
"eslint": "8.51.0",
"eslint-config-silverwind": "76.0.4",
"updates": "15.0.2",
"versions": "11.1.0",
"vitest": "0.34.6",
"vitest-config-silverwind": "3.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc