All files / node-ipc/entities Defaults.js

92.42% Statements 61/66
57.14% Branches 4/7
100% Functions 3/3
92.42% Lines 61/66

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 64 65 66 677x 7x 7x 7x 7x 29x 29x 7x 7x 7x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 7x 7x 7x 29x 29x 29x 29x 29x 29x           29x 29x 7x 7x 7x 7x 7x  
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;
 
    readableAll = false;
    writableAll = false;
 
    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
}