function findFragmentByPTS(fragPrevious, fragments, bufferEnd, maxFragLookUpTolerance) {
  if (bufferEnd === void 0) {
    bufferEnd = 0;
  }

  if (maxFragLookUpTolerance === void 0) {
    maxFragLookUpTolerance = 0;
  }

  var fragNext = null;

  if (fragPrevious) {
    fragNext = fragments[fragPrevious.sn - fragments[0].sn + 1] || null;
  } else if (bufferEnd === 0 && fragments[0].start === 0) {
    fragNext = fragments[0];
  } // Prefer the next fragment if it's within tolerance


  if (fragNext && fragmentWithinToleranceTest(bufferEnd, maxFragLookUpTolerance, fragNext) === 0) {
    return fragNext;
  } // We might be seeking past the tolerance so find the best match


  var foundFragment = _utils_binary_search__WEBPACK_IMPORTED_MODULE_1__["default"].search(fragments, fragmentWithinToleranceTest.bind(null, bufferEnd, maxFragLookUpTolerance));

  if (foundFragment) {
    return foundFragment;
  } // If no match was found return the next fragment after fragPrevious, or null


  return fragNext;
}
Finds a fragment based on the SN of the previous fragment; or based on the needs of the current buffer.
This method compensates for small buffer gaps by applying a tolerance to the start of any candidate fragment, thus
breaking any traps which would cause the same fragment to be continuously selected within a small range.
@param {*} fragPrevious - The last frag successfully appended
@param {Array} fragments - The array of candidate fragments
@param {number} [bufferEnd = 0] - The end of the contiguous buffered range the playhead is currently within
@param {number} maxFragLookUpTolerance - The amount of time that a fragment's start/end can be within in order to be considered contiguous
@returns {*} foundFrag - The best matching fragment