code: function prepareBuffer(buffer, position) {
                  var j;
                  while (buffer[position] == undefined && buffer.length < getMaskLength()) {
                      j = 0;
                      while (getActiveBufferTemplate()[j] !== undefined) { //add a new buffer
                          buffer.push(getActiveBufferTemplate()[j++]);
                      }
                  }
  
                  return position;
              }
docs: needed to handle the non-greedy mask repetitions