Skip to content

Instantly share code, notes, and snippets.

@dimaShin
Created February 2, 2017 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaShin/67b4836c7f7b8bff99010e0bc7dcce0a to your computer and use it in GitHub Desktop.
Save dimaShin/67b4836c7f7b8bff99010e0bc7dcce0a to your computer and use it in GitHub Desktop.
const events = group.events;
const aggregatedRanges = [ new AggregatedRange(events[0]) ];
for (let i = 1; i < events.length; i++) {
const range = aggregatedRanges[aggregatedRanges.length -1];
const event = events[i];
if (event.data.start < range.end) {
range.events.push(event);
if (event.data.end > range.end) {
range.end = event.data.end;
}
} else {
aggregatedRanges.push(new AggregatedRange(event));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment