Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Created October 8, 2020 01:37
Show Gist options
  • Save krzyzanowskim/d7e8e0a8fc7f17e7d5278aa4ce4dd2eb to your computer and use it in GitHub Desktop.
Save krzyzanowskim/d7e8e0a8fc7f17e7d5278aa4ce4dd2eb to your computer and use it in GitHub Desktop.
// 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