All files / node-ipc/entities Defaults.js

92.06% Statements 58/63
57.14% Branches 4/7
100% Functions 3/3
92.06% Lines 58/63

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 642x 2x 2x 2x 2x 10x 10x 2x 2x 2x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 2x 2x 2x 10x 10x 10x 10x 10x 10x           10x 10x 2x 2x 2x 2x 2x  
import os from 'os';
 
class Defaults{
 
    constructor(){
 
    }
 
 
    appspace='app.';
    socketRoot='/tmp/';
    id=os.hostname();
 
    encoding='utf8';
    rawBuffer=false;
    sync=false;
    unlink=true;
 
    delimiter='\f';
 
    silent=false;
    logDepth=5;
    logInColor=true;
    logger=console.log.bind(console);
 
    maxConnections=100;
    retry=500;
    maxRetries=Infinity;
    stopRetrying=false;
 
    IPType=getIPType();
    tls=false;
    networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1';
    networkPort = 8000;
 
    interface={
        localAddress:false,
        localPort:false,
        family:false,
        hints:false,
        lookup:false
    }
    
}
 
function getIPType() {
    const networkInterfaces = os.networkInterfaces();
    let IPType = '';
    if (networkInterfaces
        && Array.isArray(networkInterfaces)
        && networkInterfaces.length > 0) {
        // getting the family of first network interface available
        IPType = networkInterfaces [
            Object.keys( networkInterfaces )[0]
        ][0].family;
    }
    return IPType;
}
 
export {
    Defaults as default,
    Defaults
}