function detectBidiCharacters({ sourceText, firstLineOffset }) {
  const sourceTextToSearch = sourceText.toString();

  const lines = sourceTextToSearch.split(/\r?\n/);

  return lines.reduce((reports, line, lineIndex) => {
    let match;
    let offset = lineIndex == 0 ? firstLineOffset : 0;

    while ((match = dangerousBidiCharsRegexp.exec(line)) !== null) {
      reports.push({ line: lineIndex, column: offset + match.index });
    }

    return reports;
  }, []);
}
Detects all the dangerous bidi characters in a given source text

@param {object} options - Options
@param {string} options.sourceText - The source text to search for dangerous bidi characters
@param {number} options.firstLineOffset - The offset of the first line in the source text
@returns {Array<{line: number, column: number}>} - An array of reports, each report is an
   object with the line and column of the dangerous character