• Category

    Get each line in a string. Works with LF and CRLF line endings.

    Time complexity: O(n)

    Space complexity: O(n)

    Parameters

    • string: string

      String to get the lines of

    Returns string[]

    An array of lines

    String

    Example

    lines('a\nb\r\nc'); // ['a', 'b', 'c']