External files, improve page generation
This commit is contained in:
7
CHDataManagement/Extensions/Int+Random.swift
Normal file
7
CHDataManagement/Extensions/Int+Random.swift
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
extension Int {
|
||||
|
||||
static func random() -> Int {
|
||||
random(in: Int.min...Int.max)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
extension Sequence {
|
||||
extension Collection {
|
||||
|
||||
func sorted<T>(ascending: Bool = true, using conversion: (Element) -> T) -> [Element] where T: Comparable {
|
||||
guard ascending else {
|
||||
|
@ -9,6 +9,16 @@ extension String {
|
||||
.replacingOccurrences(of: ">", with: ">")
|
||||
}
|
||||
|
||||
var removingSurroundingQuotes: String {
|
||||
if hasPrefix("\"") && hasSuffix("\"") {
|
||||
return dropBeforeFirst("\"").dropAfterLast("\"")
|
||||
}
|
||||
if hasPrefix("'") && hasSuffix("'") {
|
||||
return dropBeforeFirst("'").dropAfterLast("'")
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
var nonEmpty: String? {
|
||||
isEmpty ? nil : self
|
||||
}
|
||||
@ -30,7 +40,7 @@ extension String {
|
||||
/**
|
||||
Remove the part after the last occurence of the separator (including the separator itself).
|
||||
|
||||
The string is left unchanges, if it does not contain the separator.
|
||||
The string is left unchanged, if it does not contain the separator.
|
||||
*/
|
||||
func dropAfterLast(_ separator: String) -> String {
|
||||
guard contains(separator) else {
|
||||
|
Reference in New Issue
Block a user