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::");
const ip = stringify({number, version});
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