mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-22 04:10:40 +00:00
Documentation
This commit is contained in:
1 parent
d5b49aab17
commit
ba30f2051b
11 files changed
+20
-16
No files matched your search
@@ -1,10 +1,10 @@
|
||||
# AsyncBufferedByteIterator
|
||||
|
||||
Provides a highly efficient iterator useful for iterating byte sequences derived from asynchronous read functions.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncBufferedByteIterator.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift)]
|
||||
|
||||
Provides a highly efficient iterator useful for iterating byte sequences derived from asynchronous read functions.
|
||||
|
||||
This type provides infrastructure for creating `AsyncSequence` types with an `Element` of `UInt8` backed by file descriptors or similar read sources.
|
||||
|
||||
```swift
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Chain
|
||||
|
||||
Chains two or more asynchronous sequences together sequentially.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncChain2Sequence.swift), [Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncChain3Sequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestChain.swift)]
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Combine Latest
|
||||
|
||||
Combines the latest values produced from two or more asynchronous sequences into an asynchronous sequence of tuples.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/CombineLatest/AsyncCombineLatest2Sequence.swift), [Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/CombineLatest/AsyncCombineLatest3Sequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestCombineLatest.swift)]
|
||||
|
||||
Combines the latest values produced from two or more asynchronous sequences into an asynchronous sequence of tuples.
|
||||
|
||||
```swift
|
||||
let appleFeed = URL("http://www.example.com/ticker?symbol=AAPL").lines
|
||||
let nasdaqFeed = URL("http://www.example.com/ticker?symbol=^IXIC").lines
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# Effects
|
||||
|
||||
Lists the effects of all async algorithms.
|
||||
|
||||
| Type | Throws | Sendability |
|
||||
|-----------------------------------------------------|--------------|-------------|
|
||||
| `AsyncAdjacentPairsSequence` | rethrows | Conditional |
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Intersperse
|
||||
|
||||
Places a given value in between each element of the asynchronous sequence.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncInterspersedSequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestInterspersed.swift)]
|
||||
|
||||
Places a given value in between each element of the asynchronous sequence.
|
||||
|
||||
```swift
|
||||
let numbers = [1, 2, 3].async.interspersed(with: 0)
|
||||
for await number in numbers {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# AsyncSyncSequence
|
||||
|
||||
v
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncSyncSequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestLazy.swift)]
|
||||
|
||||
Converts a non-asynchronous sequence into an asynchronous one.
|
||||
|
||||
This operation is available for all `Sequence` types.
|
||||
|
||||
```swift
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Merge
|
||||
|
||||
Merges two or more asynchronous sequences sharing the same element type into one singular asynchronous sequence.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/Merge/AsyncMerge2Sequence.swift), [Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/Merge/AsyncMerge3Sequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestMerge.swift)]
|
||||
|
||||
Merges two or more asynchronous sequences sharing the same element type into one singular asynchronous sequence.
|
||||
|
||||
```swift
|
||||
let appleFeed = URL(string: "http://www.example.com/ticker?symbol=AAPL")!.lines.map { "AAPL: " + $0 }
|
||||
let nasdaqFeed = URL(string:"http://www.example.com/ticker?symbol=^IXIC")!.lines.map { "^IXIC: " + $0 }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Zip
|
||||
|
||||
Combines the latest values produced from two or more asynchronous sequences into an asynchronous sequence of tuples.
|
||||
|
||||
[[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/Zip/AsyncZip2Sequence.swift), [Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/Zip/AsyncZip3Sequence.swift) |
|
||||
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestZip.swift)]
|
||||
|
||||
Combines the latest values produced from two or more asynchronous sequences into an asynchronous sequence of tuples.
|
||||
|
||||
```swift
|
||||
let appleFeed = URL(string: "http://www.example.com/ticker?symbol=AAPL")!.lines
|
||||
let nasdaqFeed = URL(string: "http://www.example.com/ticker?symbol=^IXIC")!.lines
|
||||
|
||||
@@ -20,8 +20,6 @@ extension Dictionary {
|
||||
///
|
||||
/// - Parameter keysAndValues: An asynchronous sequence of key-value pairs to use for
|
||||
/// the new dictionary. Every key in `keysAndValues` must be unique.
|
||||
/// - Returns: A new dictionary initialized with the elements of
|
||||
/// `keysAndValues`.
|
||||
/// - Precondition: The sequence must not have duplicate keys.
|
||||
@inlinable
|
||||
public init<S: AsyncSequence>(uniqueKeysWithValues keysAndValues: S) async rethrows
|
||||
|
||||
@@ -25,7 +25,7 @@ where
|
||||
return AsyncMerge2Sequence(base1, base2)
|
||||
}
|
||||
|
||||
/// An ``Swift/AsyncSequence`` that takes two upstream ``Swift/AsyncSequence``s and combines their elements.
|
||||
/// An `AsyncSequence` that takes two upstream `AsyncSequence`s and combines their elements.
|
||||
public struct AsyncMerge2Sequence<
|
||||
Base1: AsyncSequence,
|
||||
Base2: AsyncSequence
|
||||
|
||||
@@ -28,7 +28,7 @@ where
|
||||
return AsyncMerge3Sequence(base1, base2, base3)
|
||||
}
|
||||
|
||||
/// An ``Swift/AsyncSequence`` that takes three upstream ``Swift/AsyncSequence``s and combines their elements.
|
||||
/// An `AsyncSequence` that takes three upstream `AsyncSequence`s and combines their elements.
|
||||
public struct AsyncMerge3Sequence<
|
||||
Base1: AsyncSequence,
|
||||
Base2: AsyncSequence,
|
||||
|
||||
Reference in new issue
Block a user