DnsUpdater/Sources/App/Util/String+Extensions.swift

32 lines
521 B
Swift
Raw Permalink Normal View History

2024-11-15 10:46:29 +01:00
import Foundation
extension String {
var singleLined: String {
components(separatedBy: .newlines)
.joined(separator: " ")
}
var trimmed: String {
trimmingCharacters(in: .whitespacesAndNewlines)
}
var nonEmpty: String? {
self != "" ? self : nil
}
}
extension Array where Element == String {
var list: String {
joined(separator: ", ")
}
}
extension Sequence where Element == String {
var sortedList: String {
sorted().list
}
}