@jiminp/tooltool
    Preparing search index...

    Function getRowCol

    • Calculates the row and column of a character index in a string.

      Parameters

      • s: string

        The string.

      • ind: number

        Zero-based character index (s.length returns position after last char).

      • Optionalpretty: false

        If true, returns 1-based "row:col"; otherwise 0-based tuple.

      Returns RowCol

      [row, col] tuple or "row:col" string.

      If ind is out of bounds.

      Line breaks are \n only; \r is treated as a regular character.

      const text = "hello\nworld";
      getRowCol(text, 0); // [0, 0]
      getRowCol(text, 6); // [1, 0]
      getRowCol(text, 6, true); // "2:1"
    • Calculates the row and column of a character index in a string.

      Parameters

      • s: string

        The string.

      • ind: number

        Zero-based character index (s.length returns position after last char).

      • pretty: true

        If true, returns 1-based "row:col"; otherwise 0-based tuple.

      Returns `${number}:${number}`

      [row, col] tuple or "row:col" string.

      If ind is out of bounds.

      Line breaks are \n only; \r is treated as a regular character.

      const text = "hello\nworld";
      getRowCol(text, 0); // [0, 0]
      getRowCol(text, 6); // [1, 0]
      getRowCol(text, 6, true); // "2:1"