Skip to content

Instantly share code, notes, and snippets.

@Ginden
Created November 17, 2014 18:00
Show Gist options
  • Save Ginden/696eb2c8e2b7cad4ead1 to your computer and use it in GitHub Desktop.
Save Ginden/696eb2c8e2b7cad4ead1 to your computer and use it in GitHub Desktop.
tokens.map(function(el, i, arr) {
var nextEl = arr[i + 1]; // get next element in array
if (nextEl != null && nextEl.constructor === el.constructor && el.by !== undefined) {
nextEl.by += el.by;
el.toRemove = true; // mark items to remove
}
return el;
}).filter(function(el) {
return !el.toRemove;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment