Import old content, load from disk
This commit is contained in:
9
CHDataManagement/Extensions/Optional+Extensions.swift
Normal file
9
CHDataManagement/Extensions/Optional+Extensions.swift
Normal file
@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
extension Optional {
|
||||
|
||||
func map<T>(_ transform: (Wrapped) throws -> T?) rethrows -> T? {
|
||||
guard let self else { return nil }
|
||||
return try transform(self)
|
||||
}
|
||||
}
|
11
CHDataManagement/Extensions/Sequence+Sorted.swift
Normal file
11
CHDataManagement/Extensions/Sequence+Sorted.swift
Normal file
@ -0,0 +1,11 @@
|
||||
import Foundation
|
||||
|
||||
extension Sequence {
|
||||
|
||||
func sorted<T>(ascending: Bool = true, using conversion: (Element) -> T) -> [Element] where T: Comparable {
|
||||
guard ascending else {
|
||||
return sorted { conversion($0) > conversion($1) }
|
||||
}
|
||||
return sorted { conversion($0) < conversion($1) }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user