<commit_before>/*!
 * Module dependencies.
 */

var net = require('net'),
    ip = require('ip')
/**
 * Get the ip address of the current machine
 *
 * Creates a local server to serve up the project. The intended
 * receiver is the PhoneGap App but any browser can consume the
 * content.
 *
 * Arguments:
 *
 *   -  `callback` Function ( will be called with 2 args)  
 *
 * Return:
 *
 *   - nil
 *
 * Example:
 *
 *  getIP(function(err,ip){
 *      if(err) {
 *          console.log("Oops, this happened : " + err);
 *      }
 *      else {
 *          console.log("Got the ip! it is : " + ip);
 *      }
 *  });
 *
 */


module.exports.ipAddress = null;

module.exports = function(callback) {

    if(module.exports.ipAddress != null) {
        process.nextTick(function() {
            callback(null, module.exports.ipAddress);
        });
    }
    else {
        var socket = net.createConnection(80, 'www.google.com');
            socket.on('connect', function() {
                module.exports.ipAddress = socket.address().address;
                socket.end();
                if (module.exports.ipAddress == '127.0.0.1') {
                    module.exports.ipAddress = ip.address();
                }
                callback(null, module.exports.ipAddress);
            });

        socket.on('error', function(e) {
            callback(e);
        });
    }
}<commit_msg>[lib] Fix getIP syntax formatting.<commit_after>/*!
 * Module dependencies.
 */

var net = require('net'),
    ip = require('ip');

/**
 * Get IP address of local machine.
 *
 * Creates a local server to serve up the project. The intended
 * receiver is the PhoneGap App but any browser can consume the
 * content.
 *
 * Arguments:
 *
 *   - `callback` {Function} will be triggered on competion.
 *     - `e` {Error} is null unless there is an error.
 *     - `address` {String} is the IP address.
 *
 * Example:
 *
 *    getIP(function(e, address) {
 *        if (e) {
 *            console.log('error:', e);
 *        }
 *        else {
 *            console.log('IP address:', address);
 *        }
 *    });
 */

module.exports = function(callback) {
    if (module.exports.ipAddress !== null) {
        process.nextTick(function() {
            callback(null, module.exports.ipAddress);
        });
    }
    else {
        var socket = net.createConnection(80, 'www.google.com');
            socket.on('connect', function() {
                module.exports.ipAddress = socket.address().address;
                socket.end();
                if (module.exports.ipAddress === '127.0.0.1') {
                    module.exports.ipAddress = ip.address();
                }
                callback(null, module.exports.ipAddress);
            });

        socket.on('error', function(e) {
            callback(e);
        });
    }
};

/**
 * Cache IP Address.
 */

module.exports.ipAddress = null;
{'fraction_non_alphanumeric': 0.14667128987517336, 'fraction_numerical': 0.005894590846047157, 'mean_word_length': 1.8564356435643565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '575116', 'n_tokens_mistral': 858, 'n_tokens_neox': 832, 'n_words': 201}