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::");
const ip = stringifyIp({number, version});
API
parseIp(ip)
Parse a IP address string to a object.
For IPv4 returns {number, version}
.
For IPv6 returns {number, version, [ipv4mapped], [scopeid]}
.
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