discover-providers.js
function createFromOpts(opts) {
    opts = opts || {};

    if (typeof opts === 'function') {
        return opts;
    }
    if (typeof opts === 'string') {
        return createJsonFileDiscoverProvider(opts);
    }
    if (Array.isArray(opts)) {
        return createStaticHostsProvider(opts);
    }

    var discoverProvider;
    if (opts.discoverProvider) {
        discoverProvider = opts.discoverProvider;
    } else if (opts.hosts) {
        discoverProvider = createStaticHostsProvider(opts.hosts);
    } else if (opts.bootstrapFile && typeof opts.bootstrapFile === 'string') {
        discoverProvider = createJsonFileDiscoverProvider(opts.bootstrapFile);
    } else if (opts.bootstrapFile && Array.isArray(opts.bootstrapFile)) {
        /* This weird case is added for backwards compatibility :( */
        discoverProvider = createStaticHostsProvider(opts.bootstrapFile);
    } else {
        return null;
    }

    if (opts.retry) {
        discoverProvider = retryDiscoverProvider(opts.retry, discoverProvider);
    }
    return discoverProvider;
}
function createFromOpts(opts) {
    opts = opts || {};

    if (typeof opts === 'function') {
        return opts;
    }
    if (typeof opts === 'string') {
        return createJsonFileDiscoverProvider(opts);
    }
    if (Array.isArray(opts)) {
        return createStaticHostsProvider(opts);
    }

    var discoverProvider;
    if (opts.discoverProvider) {
        discoverProvider = opts.discoverProvider;
    } else if (opts.hosts) {
        discoverProvider = createStaticHostsProvider(opts.hosts);
    } else if (opts.bootstrapFile && typeof opts.bootstrapFile === 'string') {
        discoverProvider = createJsonFileDiscoverProvider(opts.bootstrapFile);
    } else if (opts.bootstrapFile && Array.isArray(opts.bootstrapFile)) {
        /* This weird case is added for backwards compatibility :( */
        discoverProvider = createStaticHostsProvider(opts.bootstrapFile);
    } else {
        return null;
    }

    if (opts.retry) {
        discoverProvider = retryDiscoverProvider(opts.retry, discoverProvider);
    }
    return discoverProvider;
}
function createFromOpts ( opts ) { opts = opts || { } ; if ( typeof opts === 'function' ) { return opts ; } if ( typeof opts === 'string' ) { return createJsonFileDiscoverProvider ( opts ) ; } if ( Array . isArray ( opts ) ) { return createStaticHostsProvider ( opts ) ; } var discoverProvider ; if ( opts . discoverProvider ) { discoverProvider = opts . discoverProvider ; } else if ( opts . hosts ) { discoverProvider = createStaticHostsProvider ( opts . hosts ) ; } else if ( opts . bootstrapFile && typeof opts . bootstrapFile === 'string' ) { discoverProvider = createJsonFileDiscoverProvider ( opts . bootstrapFile ) ; } else if ( opts . bootstrapFile && Array . isArray ( opts . bootstrapFile ) ) { /* This weird case is added for backwards compatibility :( */ discoverProvider = createStaticHostsProvider ( opts . bootstrapFile ) ; } else { return null ; } if ( opts . retry ) { discoverProvider = retryDiscoverProvider ( opts . retry , discoverProvider ) ; } return discoverProvider ; }
Creates a DiscoverProvider from the provided options.

@param opts: an object configuring the DiscoverProvider:
- if opts or opts.discoverProvider is a function, it's returned as the {DiscoverProvider}.
- if opts or opts.hosts is an array, a static hosts discover provider is returned (see {createStaticHostsProvider})
- if opts or opts.bootstrapFile is a string, a json file discover provider is returned (see {createJsonFileDiscoverProvider})
- if opts.retry is set, the discover provider is wrapped using retryDiscoverProvider (see {retryDiscoverProvider}).

@returns {DiscoverProvider} The discover provider.
Creates a DiscoverProvider from the provided options .