index.js
function get (url, cb) {
  var urls = [], end
  _get(url, cb)
  function _get (url) {
    urls.push(url)
    if(end) return
    if(urls.length > 5)
      cb(end = new Error('too many redirects\n'+JSON.stringify(urls)))

    console.error('GET', url)
    ;(/^https/.test(url) ? https : http).get(url, function next (res) {

      if(res.statusCode >= 300 && res.statusCode < 400)
        _get(res.headers.location)
      else {
        end = true,
        cb(null, res)
      }
    })
    .on('error', function (err) {
      if(!end)
        cb(end = err)
    })
  }
}
function get (url, cb) {
  var urls = [], end
  _get(url, cb)
  function _get (url) {
    urls.push(url)
    if(end) return
    if(urls.length > 5)
      cb(end = new Error('too many redirects\n'+JSON.stringify(urls)))

    console.error('GET', url)
    ;(/^https/.test(url) ? https : http).get(url, function next (res) {

      if(res.statusCode >= 300 && res.statusCode < 400)
        _get(res.headers.location)
      else {
        end = true,
        cb(null, res)
      }
    })
    .on('error', function (err) {
      if(!end)
        cb(end = err)
    })
  }
}
function get ( url , cb ) { var urls = [ ] , end _get ( url , cb ) function _get ( url ) { urls . push ( url ) if ( end ) return if ( urls . length > 5 ) cb ( end = new Error ( 'too many redirects\n' + JSON . stringify ( urls ) ) ) console . error ( 'GET' , url ) ; ( / ^https / . test ( url ) ? https : http ) . get ( url , function next ( res ) { if ( res . statusCode >= 300 && res . statusCode < 400 ) _get ( res . headers . location ) else { end = true , cb ( null , res ) } } ) . on ( 'error' , function ( err ) { if ( ! end ) cb ( end = err ) } ) } }
pull a package from the registry
pull a package from the registry