textConvert
    Preparing search index...

    Function normalizeLineEndings

    • Normalizes line endings to LF (\n), converting both CRLF (\r\n) and lone CR (\r) -- useful for comparing or hashing text that may have come from different platforms (e.g. Windows-authored input).

      Parameters

      • text: string

        Text to normalize.

      Returns string

      The text with all line endings converted to \n.

      normalizeLineEndings('line1\r\nline2\rline3'); // 'line1\nline2\nline3'