lib/druid.js
function getLessLoaded(client, dataSource) {
  var ids = client.dataSources[dataSource]
    , nodes
    , node

  nodes = ids.map(id2client)

  function id2client(id) {
    return client.nodes[id]
  }

  node = nodes.reduce(lessLoaded)

  function lessLoaded(nodeA, nodeB) {
    if (nodeA.active < nodeB.active) {
      return nodeA
    }
    else {
      return nodeB
    }
  }

  return node
}
function getLessLoaded(client, dataSource) {
  var ids = client.dataSources[dataSource]
    , nodes
    , node

  nodes = ids.map(id2client)

  function id2client(id) {
    return client.nodes[id]
  }

  node = nodes.reduce(lessLoaded)

  function lessLoaded(nodeA, nodeB) {
    if (nodeA.active < nodeB.active) {
      return nodeA
    }
    else {
      return nodeB
    }
  }

  return node
}
function getLessLoaded ( client , dataSource ) { var ids = client . dataSources [ dataSource ] , nodes , node nodes = ids . map ( id2client ) function id2client ( id ) { return client . nodes [ id ] } node = nodes . reduce ( lessLoaded ) function lessLoaded ( nodeA , nodeB ) { if ( nodeA . active < nodeB . active ) { return nodeA } else { return nodeB } } return node }
Bad-ass load-balancing

@param {Druid} client Client instance
@param {string} dataSource Data source name
@returns {DruidNode}
Bad - ass load - balancing