-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add concurrency bridge to Promise. (#50)
Co-authored-by: Oguz Yuksel <oguz.yueksel@teufel.de>
- Loading branch information
1 parent
6b9bd39
commit fe3a226
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
Sources/FoundationExtensions/Concurrency/AsyncSequence.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright © 2023 Lautsprecher Teufel GmbH. All rights reserved. | ||
|
||
import _Concurrency | ||
|
||
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | ||
extension AsyncSequence { | ||
|
||
/// Returns a new asynchronous sequence that transforms the elements of the sequence using a key path. | ||
/// | ||
/// This method works as a shortcut for the `map` function, specifically using a key path as the transform function. Each element of the sequence is transformed to the value at the specified key path of the element. | ||
/// | ||
/// - Parameter kp: A key path that specifies which property value to map from each element in the sequence. | ||
/// - Returns: A new asynchronous sequence that contains the transformed elements. Each element is the value at the specified key path of the corresponding element in the original sequence. | ||
@inlinable | ||
public func map<Value>(_ kp: KeyPath<Element, Value>) -> AsyncMapSequence<Self, Value> { | ||
map { $0[keyPath: kp] } | ||
} | ||
} |
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