code: function stepsToIndex(length, allowWrap, fromSelection, toSelection) {
    let steps = toSelection - fromSelection;
    // Wrapping only kicks in when list has more than 1 item.
    if (allowWrap && length > 1) {
      const wrapSteps = length - Math.abs(steps);
      if (wrapSteps <= 1) {
        // Special case
        steps = steps < 0 ?
          wrapSteps :   // Wrap forward from last item to first.
          -wrapSteps;   // Wrap backward from first item to last.
      }
    }
    return steps;
  }
docs: /*
  Figure out how many steps it will take to go from fromSelection to
  toSelection. To go from item 3 to item 4 is one step.
  
  If wrapping is allowed, then going from the last item to the first will take
  one step (forward), and going from the first item to the last will take one
  step (backward).