DnsUpdater/Sources/App/Util/String+Extensions.swift
Christoph Hagen 9b6fd627ac First version
2024-11-15 10:46:29 +01:00

32 lines
521 B
Swift

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
}
}