This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public final class URLDecoder: Decoder { | |
public var codingPath: [CodingKey] = [] | |
public var userInfo: [CodingUserInfoKey: Any] = [:] | |
let parseParametersFromURL: (URL) throws -> [String: Any] | |
public init<Output>(_ regex: Regex<Output>) { | |
self.parseParametersFromURL = { url in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Tuple<each T> { | |
public private(set) var value: (repeat each T) | |
public init(_ value: repeat each T) { self.value = (repeat each value) } | |
} | |
extension Tuple { | |
public func map<each U>( | |
_ transform: (repeat each T) throws -> (repeat each U) | |
) rethrows -> (repeat each U) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol CGContextRepresentable: View { | |
func draw(in context: CGContext, frame: CGRect) | |
} | |
extension CGContextRepresentable { | |
var body: some View { _CGContextView(draw: draw) } | |
} | |
private struct _CGContextView: UIViewRepresentable { | |
let draw: (CGContext, CGRect) -> Void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
public struct OnChangeObservable<Value: Equatable> { | |
private var storage: Storage | |
public var wrappedValue: Value { | |
get { storage.value } | |
set { storage.value = newValue } | |
} | |
public var projectedValue: OnChangeObservable<Value> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func combineLatest<C>( | |
_ collection: C, | |
bufferingPolicy limit: AsyncStream<[C.Element.Element]>.Continuation.BufferingPolicy = .unbounded | |
) -> AsyncStream<[C.Element.Element]> where C: Collection, C.Element: AsyncSequence { | |
AsyncStream(bufferingPolicy: limit) { continuation in | |
let stream = CombineLatestActor<C.Element.Element>(collection.count) | |
continuation.onTermination = { @Sendable termination in | |
switch termination { | |
case .cancelled: Task { await stream.cancel() } | |
case .finished: break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func isEqual(_ x: Any, _ y: Any) -> Bool { | |
if let isEqual = (x as? any Equatable)?.isEqual(to: y) { | |
return isEqual | |
} else if let equatable = x as? AnyEquatable { | |
return equatable.isEqual(to: y) | |
} else { | |
return (x as? any OptionalProtocol).isNil && (y as? any OptionalProtocol).isNil | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import Foundation | |
extension Publisher { | |
public func retry<S: Scheduler>( | |
_ max: Int = Int.max, | |
delay: Publishers.RetryDelay<Self, S>.TimingFunction, | |
scheduler: S | |
) -> Publishers.RetryDelay<Self, S> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Executable { | |
let url: URL | |
public init(_ filePath: String) { | |
url = URL(fileURLWithPath: filePath) | |
} | |
public init(_ url: URL) { | |
self.url = url |
NewerOlder