discover-providers.js
function createJsonFileDiscoverProvider(hostsFile) {
    var fs = require('fs');

    return function jsonFileProvider(callback) {
        fs.readFile(hostsFile, function onFileRead(err, data) {
            if (err) {
                callback(err);
                return;
            }

            var hosts;
            try {
                hosts = JSON.parse(data.toString());
            } catch (e) {
                callback(e);
                return;
            }
            callback(null, hosts);
            return;
        });
    };
}
function createJsonFileDiscoverProvider(hostsFile) {
    var fs = require('fs');

    return function jsonFileProvider(callback) {
        fs.readFile(hostsFile, function onFileRead(err, data) {
            if (err) {
                callback(err);
                return;
            }

            var hosts;
            try {
                hosts = JSON.parse(data.toString());
            } catch (e) {
                callback(e);
                return;
            }
            callback(null, hosts);
            return;
        });
    };
}
function createJsonFileDiscoverProvider ( hostsFile ) { var fs = require ( 'fs' ) ; return function jsonFileProvider ( callback ) { fs . readFile ( hostsFile , function onFileRead ( err , data ) { if ( err ) { callback ( err ) ; return ; } var hosts ; try { hosts = JSON . parse ( data . toString ( ) ) ; } catch ( e ) { callback ( e ) ; return ; } callback ( null , hosts ) ; return ; } ) ; } ; }
Create a new DiscoverProvider using a host-file.
@param {string} hostsFile The path to a json file containing an array of strings.
@returns {DiscoverProvider}
Create a new DiscoverProvider using a host - file .