code: function addPatch(patches, patch) {
  	var lastPatch = patches[patches.length -1];
  	if(lastPatch) {
  		// same number of deletes and counts as the index is back
  		if(lastPatch.deleteCount === lastPatch.insert.length && (patch.index - lastPatch.index === lastPatch.deleteCount) ) {
  			lastPatch.insert.push.apply(lastPatch.insert, patch.insert);
  			lastPatch.deleteCount += patch.deleteCount;
  			return;
  		}
  	}
  	patches.push(patch);
  }
docs: combines patches if it makes sense