Skip to content

toLong()

Evgheniy Kovaliov edited this page Jul 26, 2023 · 1 revision

toLong(ip)

Description

Method that allows you convert ipv6 address to long(expanded) form.
Ipv6 address must be correct. (see validation)

Contract

Parameters:

  • ip: string — ipv6 address to convert.

Return:

  • longIp: string — long form of ipv6 address.
Exceptions

Invalide ip address!:

  • entered argument is not a correct ipv6 address.
Usage
ipv6.toLong('::');                                      // '0000:0000:0000:0000:0000:0000:0000:0000'
ipv6.toLong('::aFf1');                                  // '0000:0000:0000:0000:0000:0000:0000:aFf1'
ipv6.toLong('aFf1::');                                  // 'aFf1:0000:0000:0000:0000:0000:0000:0000'
ipv6.toLong('aFf1::aFf1');                              // 'aFf1:0000:0000:0000:0000:0000:0000:aFf1'
ipv6.toLong('a::F');                                    // '000a:0000:0000:0000:0000:0000:0000:000F'
ipv6.toLong('a:22:333:4444:cc:d::F');                   // '000a:0022:0333:4444:00cc:000d:0000:000F'
ipv6.toLong('7759:f8bf:2d23:7be9:25fb:adab:b6b5:b7a9'); // '7759:f8bf:2d23:7be9:25fb:adab:b6b5:b7a9'

ipv6.toLong('GG::WP');                                  // Error: Invalide ip address!

MAIN PAGE

See all methods documentation:

For ip version 4

For ip version 6

Clone this wiki locally