function removeDuplicates(indexes, search) {
	const array = [];

	indexes.forEach(matchingIndex => {
		if (array.length === 0) {
			array.push(matchingIndex);
		} else if (matchingIndex >= array[array.length - 1] + search.length) {
			array.push(matchingIndex);
		}
	});

	return array;
}
/**
 * This function allow to remove 'duplicates' indexes ( when same character is typed for example
 * : label : "aaaaa" for searched string "aa")
 *
 * @param indexes list of indexes
 * @param search searchCriteria
 */
This function allow to remove 'duplicates' indexes ( when same character is typed for example
: label : "aaaaa" for searched string "aa")

@param indexes list of indexes
@param search searchCriteria
This function allow to remove ' duplicates ' indexes ( when same character is typed for example : label : " aaaaa " for searched string " aa " ) @param indexes list of indexes @param search searchCriteria
function removeDuplicates(indexes, search) {
	const array = [];
	indexes.forEach(matchingIndex => {
		if (array.length === 0) {
			array.push(matchingIndex);
		} else if (matchingIndex >= array[array.length - 1] + search.length) {
			array.push(matchingIndex);
		}
	});
	return array;
}
function removeDuplicates ( indexes , search ) { const array = [ ] ; indexes . forEach ( matchingIndex => { if ( array . length === 0 ) { array . push ( matchingIndex ) ; } else if ( matchingIndex >= array [ array . length - 1 ] + search . length ) { array . push ( matchingIndex ) ; } } ) ; return array ; }
This function allow to remove 'duplicates' indexes ( when same character is typed for example
 : label : "aaaaa" for searched string "aa")
This function allow to remove ' duplicates ' indexes ( when same character is typed for example : label : " aaaaa " for searched string " aa " )