ip-bigint
Advanced tools
Weekly downloads
Changelog
6.0.0
Removed the validation on parseIp
, which means error messages may be different for invalid IPs.
Readme
Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
npm i ip-bigint
import {parseIp, stringifyIp} from "ip-bigint";
const {number, version} = parseIp("2001:db8::");
// => {number: 42540766411282592856903984951653826560n, version: 6}
const ip = stringifyIp({number, version});
// => "2001:db8::"
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
.
Convert a object to string. Returns ip
. For IPv6, ip
is normalized to the "best representation" all-lowercase shortest possible form.
The module exports max4
and max6
properties which represent the biggest possible BigInt for IPv4 and IPv6 respectively.
© silverwind, distributed under BSD licence
FAQs
Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
The npm package ip-bigint receives a total of 478 weekly downloads. As such, ip-bigint popularity was classified as not popular.
We found that ip-bigint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.