Created
October 8, 2020 01:37
-
-
Save krzyzanowskim/d7e8e0a8fc7f17e7d5278aa4ce4dd2eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/apple/swift-algorithms | |
import Algorithms | |
extension String { | |
func lineChunks() -> [Self.SubSequence] { | |
chunked { | |
!( | |
($0.isNewline && !$1.isNewline) || ($0.isNewline && $1.isNewline) && !($0 == "\r" && $1 == "\n") | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment