1.0.1 • Published 2 years ago

group-by-range v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

group-by-range

Usage

const { groupByRange } = require("group-by-range");

const collection = [
  {widgets: 1},
  {widgets: 3},
  {widgets: 7},
  {widgets: 2},
  {widgets: 8},
  {widgets: 2},
]

const grouped = groupByRange(collection, [0, 5, 10], 'widgets');

/*
{
  '0,5': [ { widgets: 1 }, { widgets: 3 }, { widgets: 2 }, { widgets: 2 } ],
  '5,10': [ { widgets: 7 }, { widgets: 8 } ]
}
*/