lib/third_party/tracing/base/iteration_helpers.js
function group(ary, fn) {
    return ary.reduce(function(accumulator, curr) {
      var key = fn(curr);

      if (key in accumulator)
        accumulator[key].push(curr);
      else
        accumulator[key] = [curr];

      return accumulator;
    }, {});
  }
function group(ary, fn) {
    return ary.reduce(function(accumulator, curr) {
      var key = fn(curr);

      if (key in accumulator)
        accumulator[key].push(curr);
      else
        accumulator[key] = [curr];

      return accumulator;
    }, {});
  }
function group ( ary , fn ) { return ary . reduce ( function ( accumulator , curr ) { var key = fn ( curr ) ; if ( key in accumulator ) accumulator [ key ] . push ( curr ) ; else accumulator [ key ] = [ curr ] ; return accumulator ; } , { } ) ; }
Returns a new dictionary with items grouped by the return value of the
specified function being called on each item.
@param {!Array.<Object>} ary The array being iterated through
@param {!Function} fn The mapping function between the array value and the
map key.
Returns a new dictionary with items grouped by the return value of the specified function being called on each item .