Private
constructorPrivate
Private constructor. Use IP.newFromText instead.
An object that stores CIDR information.
Evaluate whether the IP address associated with this instance contains that associated
with ipStr
.
null
if ipStr
does not represent an IP address.
Evaluate whether the IP address associated with this instance contains all IP addresses
in the ipArr
array.
An array of IP- or CIDR-representing strings or IP instances.
null
if ipArr
is not an array or an empty array.
Evaluate whether the IP address associated with this instance contains any IP address
in the ipArr
array.
An array of IP- or CIDR-representing strings or IP instances.
The index number of the first match in the ipArr
array, or -1
otherwise.
Evaluate whether the IP address associated with this intance equals that associated
with ipStr
.
An IP- or CIDR-representing string, or an IP instance.
null
if ipStr
does not represent an IP address.
Evaluate whether the IP address associated with this intance equals all IP addresses
in the ipArr
array.
An array of IP- or CIDR-representing strings or IP instances.
null
if ipArr
is not an array or an empty array.
Evaluate whether the IP address associated with this intance equals any IP address
in the ipArr
array.
An array of IP- or CIDR-representing strings or IP instances.
The index number of the first match in the ranges
array, or -1
otherwise.
Get the bit length of the IP instance.
Note that this always returns a number between 0-32
for IPv4 and 0-128
for IPv6.
To evaluate whether the instance is a CIDR, use IP.isCIDR.
Get a copy of the private instance properties as an object.
Get range information of the IP instance. The return value includes:
Optional
getObject: falseOptional
options: StringifyOptionsGet range information of the IP instance. The return value includes:
Optional
options: StringifyOptionsEvaluate whether the IP address associated with this instance is within all IP ranges
in the cidrArr
array.
An array of IP- or CIDR-representing strings or IP instances.
null
if cidrArr
is not an array or an empty array.
Evaluate whether the IP address associated with this instance is within any IP range
in the cidrArr
array.
An array of IP- or CIDR-representing strings or IP instances.
The index number of the first match in the cidrArr
array, or -1
otherwise.
Evaluate whether the IP address associated with this instance is within that associated with cidrStr
.
null
if cidrStr
does not represent an IP address.
Stringify the IP instance.
Optional
options: StringifyOptions = {}Options to specify the format of the output. If not provided, the "sanitized" format will be used.
Note that even if the instance was initialized from an inaccurate CIDR string, the output will be in a "corrected" format:
const ip = IP.newFromText('fd12:3456:789a:1::1/64');
ip.stringify(); // fd12:3456:789a:1:0:0:0:0/64
Same as IP.stringify when it's called without options.
Protected
Static
checkProtected
Check the equality of two IP addresses.
An object of arrays of the IP parts in decimals.
An IP- or CIDR-representing string, or an IP instance.
null
if ipStr
does not represent an IP address.
Static
cleanReturn a trimmed string from which all occurrences of unicode bidi characters are removed.
"Unicode bidi characters" are special characters shown as red dots in WikiEditor, which can slip into cut-and-pasted strings. When we evaluate whether a string represents an IP address, these can cause serious trouble.
Protected
Static
compareProtected
Compare two ranges to check their inclusion relationship.
An object of arrays of the IP parts in decimals.
Which of ip1
and ip2
is expected to be broader.
null
if ip2
does not represent an IP address.
Protected
Static
getProtected
Given an IP string or instance, parse it into an object of arrays of decimals that represent the parts of the first and last IPs.
null
if the input string does not represent an IP address.
Protected
Static
modStatic
newInitialize an IP instance from a string and a range (aka bit length).
An IP- or CIDR-representing string. If a CIDR string is passed, the /XX
part
will be overriden by range
.
0-32
for IPv4, 0-128
for IPv6.
null
if:
range
is invalid.Static
newProtected
Static
parseProtected
Parse a string that potentially represents an IP or CIDR address.
Optional
bitLen: numberAn optional bit length of the IP address.
A parsed object, or null
if:
ipStr
is not a string.ipStr
does not represent an IP address.ipStr
contains an invalid bit length for a CIDR.Protected
Static
parseProtected
Parse an IP string into an array and convert back into a string.
Optional
conditionPredicate: ConditionPredicateOptional IP address conditions to perform stringification.
null
if:
conditionPredicate
Protected
Static
parseProtected
Get the start and end IP addresses for the range of bitLen
as an object of arrays of decimals.
Protected
Static
stringifyProtected
Stringify an array of IP parts in decimals.
Optional
options: StringifyOptions = {}
The IP class. Unlike the static IPUtil class, this class provides several instance methods that can be used to perform validations on the same IP or CIDR address multiple times.
To initialize a new instance, use IP.newFromText (or IP.newFromRange):