ip-bigint
Convert IPv4 and IPv6 addresses to native BigInt and vice-versa
Installation
$ npm i ip-bigint
Example
const {parse, stringify} = require("ip-bigint");
const {num, version} = parse("2001:db8::");
const ip = stringify({num, version});
API
parse(ip)
Parse a IP address string. Returns {num, version}
.
stringify({num, version})
Convert a parsed IP 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