Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ip-bigint

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-bigint - npm Package Compare versions

Comparing version 3.0.3 to 4.0.0

22

index.js

@@ -1,10 +0,14 @@

"use strict";
import ipRegex from "ip-regex";
const isIP = require("is-ip");
export const max4 = 2n ** 32n - 1n;
export const max6 = 2n ** 128n - 1n;
const max4 = module.exports.max4 = 2n ** 32n - 1n;
const max6 = module.exports.max6 = 2n ** 128n - 1n;
function isIP(ip) {
if (ipRegex.v4({exact: true}).test(ip)) return 4;
if (ipRegex.v6({exact: true}).test(ip)) return 6;
return 0;
}
module.exports.parse = ip => {
const version = isIP.version(ip);
export function parseIp(ip) {
const version = isIP(ip);
if (!version) throw new Error(`Invalid IP address: ${ip}`);

@@ -60,5 +64,5 @@

}
};
}
module.exports.stringify = ({number, version, ipv4mapped, scopeid} = {}) => {
export function stringifyIp({number, version, ipv4mapped, scopeid} = {}) {
if (typeof number !== "bigint") throw new Error(`Expected a BigInt`);

@@ -103,2 +107,2 @@ if (![4, 6].includes(version)) throw new Error(`Invalid version: ${version}`);

}
};
}
{
"name": "ip-bigint",
"version": "3.0.3",
"version": "4.0.0",
"description": "Convert IPv4 and IPv6 addresses to native BigInt and vice-versa",

@@ -8,7 +8,5 @@ "author": "silverwind <me@silverwind.io>",

"license": "BSD-2-Clause",
"scripts": {
"test": "make test"
},
"type": "module",
"engines": {
"node": ">=10.4.0"
"node": ">=14"
},

@@ -19,10 +17,10 @@ "files": [

"dependencies": {
"is-ip": "3.1.0"
"ip-regex": "5.0.0"
},
"devDependencies": {
"eslint": "7.21.0",
"eslint-config-silverwind": "29.0.0",
"jest": "26.6.3",
"updates": "11.4.3",
"versions": "8.4.5"
"eslint": "8.23.1",
"eslint-config-silverwind": "54.0.2",
"jest": "29.0.3",
"updates": "13.1.5",
"versions": "9.3.0"
},

@@ -29,0 +27,0 @@ "keywords": [

@@ -15,8 +15,8 @@ # ip-bigint

```js
const {parse, stringify} = require("ip-bigint");
const {parseIp, stringifyIp} = require("ip-bigint");
const {number, version} = parse("2001:db8::");
const {number, version} = parseIp("2001:db8::");
// => number: 42540766411282592856903984951653826560n
// => version: 6
const ip = stringify({number, version});
const ip = stringifyIp({number, version});
// => "2001:db8::"

@@ -27,3 +27,3 @@ ```

### parse(ip)
### parseIp(ip)

@@ -35,3 +35,3 @@ Parse a IP address string to a object.

### stringify({number, version, [ipv4mapped], [scopeid]})
### stringifyIp({number, version, [ipv4mapped], [scopeid]})

@@ -42,3 +42,3 @@ Convert a object to string. Returns `ip`. For IPv6, `ip` is normalized to the "best representation" all-lowercase shortest possible form.

The module additionally exports `max4` and `max6` properties which represent the biggest possible BigInt for IPv4 and IPv6 respectively.
The module exports `max4` and `max6` properties which represent the biggest possible BigInt for IPv4 and IPv6 respectively.

@@ -45,0 +45,0 @@ ## License

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc