src/type-registry.js
/**
 * Loads the public and private type registry index resources, adds them
 * to the profile, and returns the profile.
 * Called by the profile.loadTypeRegistry() alias method.
 * Usage:
 *
 *   ```
 * var profile = solid.getProfile(url, options)
 *   .then(function (profile) {
 *     return profile.loadTypeRegistry(options)
 *   })
 *   ```
 * @method loadTypeRegistry
 * @param profile {SolidProfile}
 * @param webClient {SolidWebClient}
 * @param [options] Options hashmap (see solid.web.solidRequest() function docs)
 * @return {Promise<SolidProfile>}
 */
Loads the public and private type registry index resources, adds them
to the profile, and returns the profile.
Called by the profile.loadTypeRegistry() alias method.
Usage.


Loads the public and private type registry index resources adds them to the profile and returns the profile . Called by the profile . loadTypeRegistry () alias method . Usage .
function loadTypeRegistry (profile, webClient, options) {
  options = options || {}
  options.headers = options.headers || {}
  if (!options.headers['Accept']) {
    options.headers['Accept'] = 'text/turtle'
  }
  var links = []
  if (profile.typeIndexListed.uri) {
    links.push(profile.typeIndexListed.uri)
  }
  if (profile.typeIndexUnlisted.uri) {
    links.push(profile.typeIndexUnlisted.uri)
  }
  return webClient.loadParsedGraphs(links, options)
    .then(function (loadedGraphs) {
      const allFailed = loadedGraphs.length &&
        loadedGraphs.reduce((acc, cur) => acc && !cur.value, true)
      if (allFailed) {
        throw new Error('Could not load any type index')
      }
      loadedGraphs.forEach(function (graph) {
        if (graph && graph.value) {
          profile.addTypeRegistry(graph.value, graph.uri)
        }
      })
      return profile
    })
}
function loadTypeRegistry ( profile , webClient , options ) { options = options || { } options . headers = options . headers || { } if ( ! options . headers [ 'Accept' ] ) { options . headers [ 'Accept' ] = 'text/turtle' } var links = [ ] if ( profile . typeIndexListed . uri ) { links . push ( profile . typeIndexListed . uri ) } if ( profile . typeIndexUnlisted . uri ) { links . push ( profile . typeIndexUnlisted . uri ) } return webClient . loadParsedGraphs ( links , options ) . then ( function ( loadedGraphs ) { const allFailed = loadedGraphs . length && loadedGraphs . reduce ( ( acc , cur ) => acc && ! cur . value , true ) if ( allFailed ) { throw new Error ( 'Could not load any type index' ) } loadedGraphs . forEach ( function ( graph ) { if ( graph && graph . value ) { profile . addTypeRegistry ( graph . value , graph . uri ) } } ) return profile } ) }
Loads the public and private type registry index resources, adds them
 to the profile, and returns the profile.
Loads the public and private type registry index resources adds them to the profile and returns the profile .
// Politely ask for Turtle format // load public and private index resources // For each index resource loaded, add it to `profile.typeIndexListed` //  or `profile.typeIndexUnlisted` as appropriate