var arrGroup = function(arr, isNextFunction, returnSingleElements) {
  if(!returnSingleElements) returnSingleElements = true; // optional argument

  var rangeGroups  = []
    , checkBuffer  = []
    , previousItem
    , isLastItem   = false;

  arr.forEach(function(currentItem, index) {

    var flushBuffer = function() {
      rangeGroups.push(checkBuffer.map(singleRecordToElement));
      checkBuffer = [];
    }

    if(!isNextFunction(currentItem, previousItem)
       && previousItem) {
      flushBuffer();
    }

    checkBuffer.push(currentItem);

    isLastItem = (index == (arr.length-1));
    if(isLastItem) {
      flushBuffer();
    }

    previousItem = currentItem;
    return;
  });

  var rangeGroupsTrans = rangeGroups;
  if(returnSingleElements) {
    rangeGroupsTrans = rangeGroups.map(singleRecordToElement);
  }

  return rangeGroupsTrans;
};
var singleRecordToElement = function(element) {
  if(element.length == 1) {
    return element[0];
  }
  return element;
};

module.exports  = arrGroup;

@@ -67,17 +67,23 @@
  %7B%0A  if(
-!
+typeof 
 returnSi
@@ -94,17 +94,59 @@
 Elements
-)
+ == 'undefined') %7B // optional argument%0A   
  returnS
@@ -166,37 +166,20 @@
  = true;
- // optional argument
+%0A  %7D
 %0A%0A  var 

Fix returnSingleElements argument.