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

Convert IPv4 and IPv6 addresses to native BigInt and vice-versa

  • 3.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17K
decreased by-26.1%
Maintainers
1
Weekly downloads
 
Created
Source

ip-bigint

Convert IPv4 and IPv6 addresses to native BigInt and vice-versa

Install

npm i ip-bigint

Example

const {parse, stringify} = require("ip-bigint");

const {number, version} = parse("2001:db8::");
// => number: 42540766411282592856903984951653826560n
// => version: 6
const ip = stringify({number, version});
// => "2001:db8::"

API

parse(ip)

Parse a IP address string to a object.

For IPv4 returns {number, version}. For IPv6 returns {number, version, [ipv4mapped], [scopeid]}.

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

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

Constants

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

License

© silverwind, distributed under BSD licence

Keywords

FAQs

Package last updated on 05 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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