function getModifierAndComponents(range) {
  const rangeComponents = range.split(componentRegex);
  const matches = rangeComponents[0].match(modifierRegex);
  invariant(matches, 'expected regex to match but it did not');

  return {
    modifier: matches[1],
    rangeComponents: [matches[2]].concat(rangeComponents.slice(1)),
  };
}
Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version
components from `range`.

For example, given `range` ">= 1.2.3" returns an object with a `modifier` of
`">="` and `components` of `[1, 2, 3]`.

@param {string} range
@returns {object}