async function mobileNetwork(pinInput) {
    let address
    let pinInputArr
    try {
        pinInputArr = pinInput.split('.')
    } catch (e) {
        throw new Error('Invalid pin')
    }

    if (pinInput.match(/[:]/)) {
        log('type is ipv6', pinInput)
        address = `http://[${pinInput}]:8080` // ipv6 has to be places within square brackets
    } else {
        let ip = await new KeyPairing().getLocalIPAddr()
        log('localIPAddr is', ip)
        let ipArr = ip.split('.')
        switch (pinInputArr.length) {
            case 1:
                address = `http://${ipArr[0]}.${ipArr[1]}.${
                    ipArr[2]
                }.${pinInput}:8080`
                break
            case 2:
                address = `http://${ipArr[0]}.${ipArr[1]}.${pinInputArr[0]}.${
                    pinInputArr[1]
                }:8080`
                break
            case 3:
                address = `http://${ipArr[0]}.${pinInputArr[0]}.${
                    pinInputArr[1]
                }.${pinInputArr[2]}:8080`
                break
            case 4:
                address = `http://${pinInput}:8080`
                break
            default:
                log('Too many octets')
        }
        log('The address we will call is', address)
    }
    return address
}
/**
 * mobileNetwork accepts a pin input.
 * It throws an error or returns a proper address string.
 * @param {string} pinInput
 * @returns {Error | string}
 */
mobileNetwork accepts a pin input.
It throws an error or returns a proper address string.
@param {string} pinInput
@returns {Error | string}
mobileNetwork accepts a pin input . It throws an error or returns a proper address string . @param { string } pinInput @returns { Error | string }
async function mobileNetwork(pinInput) {
    let address
    let pinInputArr
    try {
        pinInputArr = pinInput.split('.')
    } catch (e) {
        throw new Error('Invalid pin')
    }
    if (pinInput.match(/[:]/)) {
        log('type is ipv6', pinInput)
        address = `http://[${pinInput}]:8080` 
    } else {
        let ip = await new KeyPairing().getLocalIPAddr()
        log('localIPAddr is', ip)
        let ipArr = ip.split('.')
        switch (pinInputArr.length) {
            case 1:
                address = `http://${ipArr[0]}.${ipArr[1]}.${
                    ipArr[2]
                }.${pinInput}:8080`
                break
            case 2:
                address = `http://${ipArr[0]}.${ipArr[1]}.${pinInputArr[0]}.${
                    pinInputArr[1]
                }:8080`
                break
            case 3:
                address = `http://${ipArr[0]}.${pinInputArr[0]}.${
                    pinInputArr[1]
                }.${pinInputArr[2]}:8080`
                break
            case 4:
                address = `http://${pinInput}:8080`
                break
            default:
                log('Too many octets')
        }
        log('The address we will call is', address)
    }
    return address
}
async function mobileNetwork ( pinInput ) { let address let pinInputArr try { pinInputArr = pinInput . split ( '.' ) } catch ( e ) { throw new Error ( 'Invalid pin' ) } if ( pinInput . match ( / [:] / ) ) { log ( 'type is ipv6' , pinInput ) address = ` ${ pinInput } ` } else { let ip = await new KeyPairing ( ) . getLocalIPAddr ( ) log ( 'localIPAddr is' , ip ) let ipArr = ip . split ( '.' ) switch ( pinInputArr . length ) { case 1 : address = ` ${ ipArr [ 0 ] } ${ ipArr [ 1 ] } ${ ipArr [ 2 ] } ${ pinInput } ` break case 2 : address = ` ${ ipArr [ 0 ] } ${ ipArr [ 1 ] } ${ pinInputArr [ 0 ] } ${ pinInputArr [ 1 ] } ` break case 3 : address = ` ${ ipArr [ 0 ] } ${ pinInputArr [ 0 ] } ${ pinInputArr [ 1 ] } ${ pinInputArr [ 2 ] } ` break case 4 : address = ` ${ pinInput } ` break default : log ( 'Too many octets' ) } log ( 'The address we will call is' , address ) } return address }
mobileNetwork accepts a pin input.
mobileNetwork accepts a pin input .
// ipv6 has to be places within square brackets