Function: parseIp()
parseIp(
input):ParsedIp|null
Parse an IPv4 ("1.2.3.4") or IPv6 ("2001:db8::1",
"::ffff:1.2.3.4", "::1") address into a ParsedIp, or
null when the input isn’t a valid literal. Never throws. Surrounding
whitespace, [...] brackets around an IPv6 literal, and an IPv6 zone
id (fe80::1%eth0) are all tolerated. The value is returned as a
bigint so v4 and v6 share one comparison path.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”ParsedIp | null
Example
Section titled “Example”parseIp("10.0.0.1"); // { version: 4, value: 167772161n }parseIp("2001:db8::1"); // { version: 6, value: ... }parseIp("not-an-ip"); // null