This file contains hidden or 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
// https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#ref--box | |
#if canImport(Combine) | |
import Combine | |
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
extension Box: ObservableObject { | |
@inlinable | |
public var publisher: AnyPublisher<Content, Never> { objectWillChange | |
.map { self.wrappedValue } |
This file contains hidden or 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 | |
func extractParametersString(from functionString: String) -> String? { | |
var buffer = String(functionString.reversed()) | |
if let returnSignIndex = buffer.range(of: "->")?.upperBound { | |
buffer = String(buffer[returnSignIndex...]) | |
} | |
if let closingBraceIndex = buffer.range(of: ")")?.upperBound { | |
buffer = String(buffer[buffer.index(before: closingBraceIndex)...]) |
This file contains hidden or 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 SwiftUI | |
struct _ViewModifier<Input: View, Output: View>: ViewModifier { | |
typealias Body = Output | |
typealias Content = _ViewModifier_Content<_ViewModifier<Input, Output>> | |
var modification: (Content) -> Output | |
func body(content: Content) -> Output { | |
modification(content) | |
} |
This file contains hidden or 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
@inlinable | |
func wrap<T>(_ value: T) -> T? { .some(value) } | |
extension Optional { | |
@inlinable | |
var isNotNil: Bool { !isNil } | |
@inlinable | |
var isNil: Bool { | |
switch self { |
This file contains hidden or 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
// NOTE: Depends on Modifications.swift | |
// NOTE: Depends on BuildBlocks.swift | |
// NOTE: Depends on FunctionalKeyPath https://gist.github.com/maximkrouk/6287fb56321a21e8180d5fe044e642e4 | |
import Foundation | |
@dynamicMemberLookup | |
public struct Builder<Object> { | |
private var _build: () -> Object | |
public func build() -> Object { _build() } |
This file contains hidden or 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 | |
/// Weakly captures an object | |
/// | |
/// Actually the same as `weak` but initializable | |
/// | |
/// Usage: | |
/// ``` | |
/// Weak(object) | |
/// Weak(self) |
This file contains hidden or 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 | |
import LocalAuthentication | |
@propertyWrapper | |
public class Authenticated { | |
public typealias Action = () -> Void | |
private var _action: Action = {} | |
private var _onStart: Action? | |
private var _onSuccess: Action? |
This file contains hidden or 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 Fluent | |
private struct _Migration<T>: Migration { | |
var preparation: (Database) -> EventLoopFuture<Void> | |
var revertion: (Database) -> EventLoopFuture<Void> | |
func prepare(on database: Database) -> EventLoopFuture<Void> { preparation(database) } | |
func revert(on database: Database) -> EventLoopFuture<Void> { revertion(database) } | |
} | |
public protocol MigrationProvider { |
This file contains hidden or 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 | |
import Combine | |
class REPL { | |
private static let shared = REPL() | |
public static var publisher: AnyPublisher<String, Never> { | |
shared.publisher.eraseToAnyPublisher() | |
} | |