function getLinePos(offset, cst) {
  if (typeof offset !== 'number' || offset < 0) return null;

  var _getSrcInfo = getSrcInfo(cst),
      lineStarts = _getSrcInfo.lineStarts,
      src = _getSrcInfo.src;

  if (!lineStarts || !src || offset > src.length) return null;

  for (var i = 0; i < lineStarts.length; ++i) {
    var start = lineStarts[i];

    if (offset < start) {
      return {
        line: i,
        col: offset - lineStarts[i - 1] + 1
      };
    }

    if (offset === start) return {
      line: i + 1,
      col: 1
    };
  }

  var line = lineStarts.length;
  return {
    line: line,
    col: offset - lineStarts[line - 1] + 1
  };
}
Determine the line/col position matching a character offset.

Accepts a source string or a CST document as the second parameter. With
the latter, starting indices for lines are cached in the document as
`lineStarts: number[]`.

Returns a one-indexed `{ line, col }` location if found, or
`undefined` otherwise.

@param {number} offset
@param {string|Document|Document[]} cst
@returns {?LinePos}