braid-design-system
Version:
Themeable design system for the SEEK Group
19 lines (18 loc) • 466 B
JavaScript
function reverseMatches(suggestion, matches) {
const suggestionLength = suggestion.length;
const reversedMatches = [];
let currentStart = 0;
for (const [start, end] of matches) {
if (currentStart < start) {
reversedMatches.push([currentStart, start]);
}
currentStart = end;
}
if (currentStart < suggestionLength) {
reversedMatches.push([currentStart, suggestionLength]);
}
return reversedMatches;
}
export {
reverseMatches
};