-
Notifications
You must be signed in to change notification settings - Fork 0
toArray()
Evgheniy Kovaliov edited this page May 9, 2023
·
1 revision
Method that allows you convert ip address to array of numbers (address' octets).
Ip address must be correct. (see validation)
Parameters:
-
ip: string— ip address to convert.
Return:
[number, number, number, number]
Invalide ip address!:
- entered argument is not a correct ip address.
ipv4.toArray('123.123.123.123'); // [123, 123, 123, 123]
ipv4.toArray('0.0.0.0'); // [0, 0, 0, 0]
ipv4.toArray('255.255.255.255'); // [255, 255, 255, 255]
ipv4.toArray('1.2.3.4'); // [1, 2, 3, 4]
ipv4.toArray('0.0.0.1'); // [0, 0, 0, 1]
ipv4.toArray('111.222.-2.0'); // Error: Invalide ip address!
ipv4.toArray('256.256.256.256'); // Error: Invalide ip address!
ipv4.toArray('10.255.255'); // Error: Invalide ip address!
ipv4.toArray('ten.zero.one.one'); // Error: Invalide ip address!
ipv4.toArray('127.0.0.0.10'); // Error: Invalide ip address!- Is used in other methods.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6