src/RawParser.js
function getRelevantIndexes(text, inlineRanges, entityRanges = [], decoratorRanges = []) {
  let relevantIndexes = [];
  // set indexes to corresponding keys to ensure uniquenes
  relevantIndexes = addIndexes(relevantIndexes, inlineRanges);
  relevantIndexes = addIndexes(relevantIndexes, entityRanges);
  relevantIndexes = addIndexes(relevantIndexes, decoratorRanges);
  // add text start and end to relevant indexes
  relevantIndexes.push(0);
  relevantIndexes.push(text.length);
  const uniqueRelevantIndexes = relevantIndexes.filter(
    (value, index, self) => self.indexOf(value) === index
  );
  // and sort it
  return uniqueRelevantIndexes.sort((aa, bb) => (aa - bb));
}
function getRelevantIndexes(text, inlineRanges, entityRanges = [], decoratorRanges = []) {
  let relevantIndexes = [];
  // set indexes to corresponding keys to ensure uniquenes
  relevantIndexes = addIndexes(relevantIndexes, inlineRanges);
  relevantIndexes = addIndexes(relevantIndexes, entityRanges);
  relevantIndexes = addIndexes(relevantIndexes, decoratorRanges);
  // add text start and end to relevant indexes
  relevantIndexes.push(0);
  relevantIndexes.push(text.length);
  const uniqueRelevantIndexes = relevantIndexes.filter(
    (value, index, self) => self.indexOf(value) === index
  );
  // and sort it
  return uniqueRelevantIndexes.sort((aa, bb) => (aa - bb));
}
function getRelevantIndexes ( text , inlineRanges , entityRanges = [ ] , decoratorRanges = [ ] ) { let relevantIndexes = [ ] ; // set indexes to corresponding keys to ensure uniquenes relevantIndexes = addIndexes ( relevantIndexes , inlineRanges ) ; relevantIndexes = addIndexes ( relevantIndexes , entityRanges ) ; relevantIndexes = addIndexes ( relevantIndexes , decoratorRanges ) ; // add text start and end to relevant indexes relevantIndexes . push ( 0 ) ; relevantIndexes . push ( text . length ) ; const uniqueRelevantIndexes = relevantIndexes . filter ( ( value , index , self ) => self . indexOf ( value ) === index ) ; // and sort it return uniqueRelevantIndexes . sort ( ( aa , bb ) => ( aa - bb ) ) ; }
Creates an array of sorted char indexes to avoid iterating over every single character
Creates an array of sorted char indexes to avoid iterating over every single character