src/async-config.js
async function loadSources (sources, options) {
  const mergedConfig = {};

  function handleSourceLoad (sourceConfig) {
    if (sourceConfig) merge(sourceConfig, mergedConfig);
  }

  for (const source of sources) {
    let sourceConfig;

    if (source == null) {
            // No-op... skip this source
      continue;
    } else if (typeof source === 'string') {
            // Load a source from a JSON file
      sourceConfig = await loadFileSource(source, options);
    } else if (Array.isArray(source)) {
      sourceConfig = await loadSources(source, options); // Load and merge all of the sources
    } else if (typeof source === 'function') {
      sourceConfig = await source(); // Invoke the function to asynchronously load the config object for this source
    } else if (typeof source === 'object') {
      sourceConfig = source; // Just merge the object
    } else {
      throw new Error('Invalid configuration source: ' + source);
    }

    handleSourceLoad(sourceConfig);
  }

  return mergedConfig;
}
async function loadSources (sources, options) {
  const mergedConfig = {};

  function handleSourceLoad (sourceConfig) {
    if (sourceConfig) merge(sourceConfig, mergedConfig);
  }

  for (const source of sources) {
    let sourceConfig;

    if (source == null) {
            // No-op... skip this source
      continue;
    } else if (typeof source === 'string') {
            // Load a source from a JSON file
      sourceConfig = await loadFileSource(source, options);
    } else if (Array.isArray(source)) {
      sourceConfig = await loadSources(source, options); // Load and merge all of the sources
    } else if (typeof source === 'function') {
      sourceConfig = await source(); // Invoke the function to asynchronously load the config object for this source
    } else if (typeof source === 'object') {
      sourceConfig = source; // Just merge the object
    } else {
      throw new Error('Invalid configuration source: ' + source);
    }

    handleSourceLoad(sourceConfig);
  }

  return mergedConfig;
}
async function loadSources ( sources , options ) { const mergedConfig = { } ; function handleSourceLoad ( sourceConfig ) { if ( sourceConfig ) merge ( sourceConfig , mergedConfig ) ; } for ( const source of sources ) { let sourceConfig ; if ( source == null ) { // No-op... skip this source continue ; } else if ( typeof source === 'string' ) { // Load a source from a JSON file sourceConfig = await loadFileSource ( source , options ) ; } else if ( Array . isArray ( source ) ) { sourceConfig = await loadSources ( source , options ) ; // Load and merge all of the sources } else if ( typeof source === 'function' ) { sourceConfig = await source ( ) ; // Invoke the function to asynchronously load the config object for this source } else if ( typeof source === 'object' ) { sourceConfig = source ; // Just merge the object } else { throw new Error ( 'Invalid configuration source: ' + source ) ; } handleSourceLoad ( sourceConfig ) ; } return mergedConfig ; }
Asynchronously load all of the configuration objects from the various sources.
Asynchronously load all of the configuration objects from the various sources .