events.js
function eachFrom(keys, key, iter) {
  var i = keys.indexOf(key)
  if(!~i) return
  //start at 1 because we want to visit all keys but key.
  for(var j = 1; j < keys.length; j++)
    if(iter(keys[(j+i)%keys.length], j))
      return
}
function eachFrom(keys, key, iter) {
  var i = keys.indexOf(key)
  if(!~i) return
  //start at 1 because we want to visit all keys but key.
  for(var j = 1; j < keys.length; j++)
    if(iter(keys[(j+i)%keys.length], j))
      return
}
function eachFrom ( keys , key , iter ) { var i = keys . indexOf ( key ) if ( ! ~ i ) return //start at 1 because we want to visit all keys but key. for ( var j = 1 ; j < keys . length ; j ++ ) if ( iter ( keys [ ( j + i ) % keys . length ] , j ) ) return }
jump to a particular key in a list, then iterate from there back around to the key. this is used for switching away from peers that stall so that you'll rotate through all the peers not just swich between two different peers.
jump to a particular key in a list then iterate from there back around to the key . this is used for switching away from peers that stall so that you ll rotate through all the peers not just swich between two different peers .