lib/utils.js
function groupPartitionsByTopic (topicPartitions) {
  assert(Array.isArray(topicPartitions));
  return topicPartitions.reduce(function (result, tp) {
    if (!(tp.topic in result)) {
      result[tp.topic] = [tp.partition];
    } else {
      result[tp.topic].push(tp.partition);
    }
    return result;
  }, {});
}
function groupPartitionsByTopic (topicPartitions) {
  assert(Array.isArray(topicPartitions));
  return topicPartitions.reduce(function (result, tp) {
    if (!(tp.topic in result)) {
      result[tp.topic] = [tp.partition];
    } else {
      result[tp.topic].push(tp.partition);
    }
    return result;
  }, {});
}
function groupPartitionsByTopic ( topicPartitions ) { assert ( Array . isArray ( topicPartitions ) ) ; return topicPartitions . reduce ( function ( result , tp ) { if ( ! ( tp . topic in result ) ) { result [ tp . topic ] = [ tp . partition ] ; } else { result [ tp . topic ] . push ( tp . partition ) ; } return result ; } , { } ) ; }
/*
Converts:

[
{topic: 'test', partition: 0},
{topic: 'test', partition: 1},
{topic: 'Bob', partition: 0}
]

Into:

{
test: [0, 1],
bob: [0]
}
/ * Converts :