resolve.js
function reduce(data, fn) {
  delete data.package.readmeFilename;   // README is already parsed.
  delete data.package.versions;         // Adds to much bloat.
  delete data.package.readme;           // README is already parsed.

  //
  // Remove circular references as it would prevent us from caching in Redis or
  // what ever because there's a circular reference. Keep track of what are main
  // dependencies by providing them with a number, useful for sorting later on.
  //
  if ('object' === typeof data.shrinkwrap) {
    Object.keys(data.shrinkwrap).forEach(function each(_id) {
      var shrinkwrap = data.shrinkwrap[_id];

      delete shrinkwrap.dependencies;
      delete shrinkwrap.dependent;
      delete shrinkwrap.parents;
    });
  }

  //
  // Extract github data from array.
  //
  if (data.github && data.github.length) data.github = data.github.pop();

  //
  // Make sure we default to something so we don't get template errors
  //
  data.readme = data.readme || data.package.description || '';

  //
  // Transform shrinkwrap to an array and prioritize on depth.
  //
  data.shrinkwrap = Object.keys(data.shrinkwrap || {}).map(function wrap(_id) {
    return data.shrinkwrap[_id];
  }).sort(function sort(a, b) {
    return a.depth - b.depth;
  });

  //
  // Remove empty objects from the package.
  //
  [
    'repository',
    'homepage',
    'bugs'
  ].forEach(function each(key) {
    if (Array.isArray(data.package[key])) {
      if (!data.package[key].length) delete data.package[key];
    } else if ('object' === typeof data.package[key] && !Object.keys(data.package[key]).length) {
      delete data.package[key];
    }
  });

  fn(undefined, data);
}
function reduce(data, fn) {
  delete data.package.readmeFilename;   // README is already parsed.
  delete data.package.versions;         // Adds to much bloat.
  delete data.package.readme;           // README is already parsed.

  //
  // Remove circular references as it would prevent us from caching in Redis or
  // what ever because there's a circular reference. Keep track of what are main
  // dependencies by providing them with a number, useful for sorting later on.
  //
  if ('object' === typeof data.shrinkwrap) {
    Object.keys(data.shrinkwrap).forEach(function each(_id) {
      var shrinkwrap = data.shrinkwrap[_id];

      delete shrinkwrap.dependencies;
      delete shrinkwrap.dependent;
      delete shrinkwrap.parents;
    });
  }

  //
  // Extract github data from array.
  //
  if (data.github && data.github.length) data.github = data.github.pop();

  //
  // Make sure we default to something so we don't get template errors
  //
  data.readme = data.readme || data.package.description || '';

  //
  // Transform shrinkwrap to an array and prioritize on depth.
  //
  data.shrinkwrap = Object.keys(data.shrinkwrap || {}).map(function wrap(_id) {
    return data.shrinkwrap[_id];
  }).sort(function sort(a, b) {
    return a.depth - b.depth;
  });

  //
  // Remove empty objects from the package.
  //
  [
    'repository',
    'homepage',
    'bugs'
  ].forEach(function each(key) {
    if (Array.isArray(data.package[key])) {
      if (!data.package[key].length) delete data.package[key];
    } else if ('object' === typeof data.package[key] && !Object.keys(data.package[key]).length) {
      delete data.package[key];
    }
  });

  fn(undefined, data);
}
function reduce ( data , fn ) { delete data . package . readmeFilename ; // README is already parsed. delete data . package . versions ; // Adds to much bloat. delete data . package . readme ; // README is already parsed. // // Remove circular references as it would prevent us from caching in Redis or // what ever because there's a circular reference. Keep track of what are main // dependencies by providing them with a number, useful for sorting later on. // if ( 'object' === typeof data . shrinkwrap ) { Object . keys ( data . shrinkwrap ) . forEach ( function each ( _id ) { var shrinkwrap = data . shrinkwrap [ _id ] ; delete shrinkwrap . dependencies ; delete shrinkwrap . dependent ; delete shrinkwrap . parents ; } ) ; } // // Extract github data from array. // if ( data . github && data . github . length ) data . github = data . github . pop ( ) ; // // Make sure we default to something so we don't get template errors // data . readme = data . readme || data . package . description || '' ; // // Transform shrinkwrap to an array and prioritize on depth. // data . shrinkwrap = Object . keys ( data . shrinkwrap || { } ) . map ( function wrap ( _id ) { return data . shrinkwrap [ _id ] ; } ) . sort ( function sort ( a , b ) { return a . depth - b . depth ; } ) ; // // Remove empty objects from the package. // [ 'repository' , 'homepage' , 'bugs' ] . forEach ( function each ( key ) { if ( Array . isArray ( data . package [ key ] ) ) { if ( ! data . package [ key ] . length ) delete data . package [ key ] ; } else if ( 'object' === typeof data . package [ key ] && ! Object . keys ( data . package [ key ] ) . length ) { delete data . package [ key ] ; } } ) ; fn ( undefined , data ) ; }
Reduce the massive data structure to something useful.

@param {Object} data The received data structure.
@param {Function} fn The callback.
@api private
Reduce the massive data structure to something useful .