examples/geojson.js
function interval(prop) {

  // create a function that will use the intervals to check the group by property
  return function(intervals) {

    // create custom labels to use for the resulting object keys
    var labels = intervals.reduce(function(acc, val, i) {
      var min = val;
      var max = (intervals[i + 1] && intervals[i + 1] - 1) || '*';
      acc[val] = min + ' - ' + max;
      return acc;
    }, {});

    // create a function that does the grouping for each item
    return function(item) {

      // value to group by
      var val = item[prop];

      // if the value falls between the interval range, return it
      // as an array to make the interval value the key being grouped by
      return intervals.filter(function(int, i) {
        var min = int;
        var max = intervals[i+1] || Infinity;
        return min <= val && val < max;
      }).map(function(int) {
        return labels[int];
      });
    };
  };
}
function interval(prop) {

  // create a function that will use the intervals to check the group by property
  return function(intervals) {

    // create custom labels to use for the resulting object keys
    var labels = intervals.reduce(function(acc, val, i) {
      var min = val;
      var max = (intervals[i + 1] && intervals[i + 1] - 1) || '*';
      acc[val] = min + ' - ' + max;
      return acc;
    }, {});

    // create a function that does the grouping for each item
    return function(item) {

      // value to group by
      var val = item[prop];

      // if the value falls between the interval range, return it
      // as an array to make the interval value the key being grouped by
      return intervals.filter(function(int, i) {
        var min = int;
        var max = intervals[i+1] || Infinity;
        return min <= val && val < max;
      }).map(function(int) {
        return labels[int];
      });
    };
  };
}
function interval ( prop ) { // create a function that will use the intervals to check the group by property return function ( intervals ) { // create custom labels to use for the resulting object keys var labels = intervals . reduce ( function ( acc , val , i ) { var min = val ; var max = ( intervals [ i + 1 ] && intervals [ i + 1 ] - 1 ) || '*' ; acc [ val ] = min + ' - ' + max ; return acc ; } , { } ) ; // create a function that does the grouping for each item return function ( item ) { // value to group by var val = item [ prop ] ; // if the value falls between the interval range, return it // as an array to make the interval value the key being grouped by return intervals . filter ( function ( int , i ) { var min = int ; var max = intervals [ i + 1 ] || Infinity ; return min <= val && val < max ; } ) . map ( function ( int ) { return labels [ int ] ; } ) ; } ; } ; }
create a function that will use the property provided to group on
create a function that will use the property provided to group on