Skip to content

fromArray()

Evgheniy Kovaliov edited this page May 9, 2023 · 1 revision

fromArray(parts)

Description

Method that allows you convert array of numbers (address' octets) into ip address.
Final ip address must be correct. (see validation)

Contract

Parameters:

  • parts: number[4] — ip address to convert.

Return:

  • ip: string
Exceptions

Invalide input type!:

  • entered argument is not an array.

Invalide array entered!:

  • final ip address is not correct.
Usage
ipv4.fromArray([123, 123, 123, 123]);     // '123.123.123.123'
ipv4.fromArray([0, 0, 0, 0]);             // '0.0.0.0'
ipv4.fromArray([255, 255, 255, 255]);     // '255.255.255.255'
ipv4.fromArray([1, 2, 3, 4]);             // '1.2.3.4'
ipv4.fromArray([0, 0, 0, 1]);             // '0.0.0.1'

ipv4.fromArray([true, true, true, true]); // Error: Invalide array entered!
ipv4.fromArray([255, 255, 255, 256]);     // Error: Invalide array entered!
ipv4.fromArray([10, 10, 10, 'one']);      // Error: Invalide array entered!
ipv4.fromArray([127, 0, 0, 0, 1]);        // Error: Invalide array entered!
ipv4.fromArray('[196, 64, 12, 0]');       // Error: Invalide input type!
  • Is used in other methods.

MAIN PAGE

See all methods documentation:

For ip version 4

For ip version 6

Clone this wiki locally