Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function advanceSelectableOption(options, currentOption, step) {
let resultsLength = countOptions(options);
let startIndex = Math.min(Math.max(indexOfOption(options, currentOption) + step, 0), resultsLength - 1);
let { disabled, option } = optionAtIndex(options, startIndex);
while (option && disabled) {
let next = optionAtIndex(options, startIndex += step);
disabled = next.disabled;
option = next.option;
}
return option;
}