applyTextGranularity = (selection, granularity) => {
  if (!selection.modify || !granularity || granularity === "symbol") return;

  try {
    switch (granularity) {
      case "word":
        boundarySelection(selection, "word");
        break;
      case "sentence":
        boundarySelection(selection, "sentenceboundary");
        break;
      case "paragraph":
        boundarySelection(selection, "paragraphboundary");
        break;
      default:
        // Handles "charater", "symbol", and any other unspecified granularities
        break;
    }
  } catch {
    console.warn("Probably, you're using browser that doesn't support granularity.");
  }
}
*Experimental feature. Might nor work in Gecko browsers.*

Updates selection's granularity.
@param {Selection} selection
@param {string} granularity