index.js
function getTarballStream (pkg, config, cb) {
  if(config.casDb && pkg.shasum) {
    var db = config.casDb
    db.has(pkg.shasum, function (err, stat) {
      if(!err)
        cb(null, db.getStream(pkg.shasum))
      else //fallback to the old way...
        tryCache()
    })
  }
  else
    tryCache()

  function tryCache () {
    var cache = getCache(pkg, config)
    fs.stat(cache, function (err) {
      if(!err)
        cb(null, fs.createReadStream(cache))
      else
        getDownload(pkg, config, cb)
    })
  }
}
function getTarballStream (pkg, config, cb) {
  if(config.casDb && pkg.shasum) {
    var db = config.casDb
    db.has(pkg.shasum, function (err, stat) {
      if(!err)
        cb(null, db.getStream(pkg.shasum))
      else //fallback to the old way...
        tryCache()
    })
  }
  else
    tryCache()

  function tryCache () {
    var cache = getCache(pkg, config)
    fs.stat(cache, function (err) {
      if(!err)
        cb(null, fs.createReadStream(cache))
      else
        getDownload(pkg, config, cb)
    })
  }
}
function getTarballStream ( pkg , config , cb ) { if ( config . casDb && pkg . shasum ) { var db = config . casDb db . has ( pkg . shasum , function ( err , stat ) { if ( ! err ) cb ( null , db . getStream ( pkg . shasum ) ) else //fallback to the old way... tryCache ( ) } ) } else tryCache ( ) function tryCache ( ) { var cache = getCache ( pkg , config ) fs . stat ( cache , function ( err ) { if ( ! err ) cb ( null , fs . createReadStream ( cache ) ) else getDownload ( pkg , config , cb ) } ) } }
stream a tarball - either from cache or registry
stream a tarball - either from cache or registry