Skip to content

Commit

Permalink
chore: PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Jul 11, 2023
1 parent 82e01d3 commit 0482d59
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 181 deletions.
4 changes: 2 additions & 2 deletions Sources/InfomaniakCore/Asynchronous/ParallelTaskMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public typealias SequenceableCollection = Sequence & Collection
///
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public struct ParallelTaskMapper {
/// internal processing TaskQueue
let taskQueue: TaskQueue
/// private processing TaskQueue
private let taskQueue: TaskQueue

/// Init function
/// - Parameter concurrency: execution depth, keep default for optimized threading.
Expand Down
49 changes: 0 additions & 49 deletions Sources/InfomaniakCore/ClosureKit/AsyncCurriedClosure.swift

This file was deleted.

10 changes: 5 additions & 5 deletions Sources/InfomaniakCore/ClosureKit/CurriedClosure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
import Foundation

/// Represents `any` (ie. all of them not the type) curried closure, of arbitrary type.
///
/// see `AsyncCurriedClosure` if you need support for structured concurrency or error feedback
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public typealias CurriedClosure<Input, Output> = (Input) -> Output

/// A closure that take no argument and return nothing, but technically curried.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
///
/// Calling this closure type requires the use of `Void` which is, in swift, an empty tuple `()`.
public typealias SimpleClosure = CurriedClosure<Void, Void>

/// Append a SimpleClosure to another one
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
///
/// This allows you to append / prepend a closure to another one with the + operator.
/// This is not function composition.
public func + (_ lhs: @escaping SimpleClosure, _ rhs: @escaping SimpleClosure) -> SimpleClosure {
let closure: SimpleClosure = { _ in
lhs(())
Expand Down
1 change: 1 addition & 0 deletions Sources/InfomaniakCore/Extensions/Bundle+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Foundation

public extension Bundle {
/// Returns `true` if executing in app extension context
var isExtension: Bool {
return bundleURL.pathExtension == "appex"
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/InfomaniakCore/Extensions/Collection+Safe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public extension Collection {
}

public extension Array {
/// Returns an `ArraySlice` for the specified indexes if possible.
/// The Slice is bounded to the size of the current collection.
subscript(safe range: Range<Index>) -> ArraySlice<Element> {
return self[Swift.min(range.startIndex, endIndex) ..< Swift.min(range.endIndex, endIndex)]
}
Expand Down
122 changes: 0 additions & 122 deletions Tests/InfomaniakCoreTests/UTAsyncCurriedClosure.swift

This file was deleted.

14 changes: 11 additions & 3 deletions Tests/InfomaniakCoreTests/UTCurriedClosure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
import InfomaniakCore
import XCTest

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public final class CountedFulfillmentTestExpectation: XCTestExpectation {
private(set) var currentFulfillmentCount = 0

override public func fulfill() {
currentFulfillmentCount += 1
super.fulfill()
}
}

final class UTCurriedClosure: XCTestCase {
func testAppendToClosure() {
// GIVEN
Expand All @@ -41,7 +49,7 @@ final class UTCurriedClosure: XCTestCase {

// WHEN
let computation = a + b
let _ = computation~
computation(())

// THEN
wait(for: expectations, timeout: 10.0)
Expand Down Expand Up @@ -77,7 +85,7 @@ final class UTCurriedClosure: XCTestCase {

// WHEN
let computation = a + b + c
let _ = computation~
computation(())

// THEN
wait(for: expectations, timeout: 10.0)
Expand Down

0 comments on commit 0482d59

Please sign in to comment.