Big news!Introducing Socket AI - ChatGPT-Powered Threat Analysis. Learn more
Socket
Log inDemoInstall

ip-bigint

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Issues
File Explorer

Advanced tools

ip-bigint

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

    6.0.0latest
    GitHub

Version published
Maintainers
1
Weekly downloads
552
decreased by-42.32%

Weekly downloads

Changelog

Source

6.0.0

Removed the validation on parseIp, which means error messages may be different for invalid IPs.

Readme

Source

ip-bigint

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

Install

npm i ip-bigint

Example

import {parseIp, stringifyIp} from "ip-bigint"; const {number, version} = parseIp("2001:db8::"); // => {number: 42540766411282592856903984951653826560n, version: 6} const ip = stringifyIp({number, version}); // => "2001:db8::"

API

parseIp(ip)

Parse a IP address string to a object (with null prototype).

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

There is only rudimentary validation that the passed string is actually an IP address. You are encouraged to validate yourself using modules like ip-regex.

stringifyIp({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 exports max4 and max6 properties which represent the biggest possible BigInt for IPv4 and IPv6 respectively.

License

© silverwind, distributed under BSD licence

Keywords

FAQs

Last updated on 13 Dec 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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