[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6946":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},6946,"swift-async-algorithms","apple\u002Fswift-async-algorithms","apple","Async Algorithms for Swift","",null,"Swift",3668,206,153,46,0,1,8,24,7,28.95,"Apache License 2.0",false,"main",true,[27],"swift","2026-06-12 02:01:32","# swift-async-algorithms\n\n**Swift Async Algorithms** is an open-source package of asynchronous sequence and advanced algorithms that involve concurrency, along with their related types.\n\nThis package has three main goals:\n\n- First-class integration with `async\u002Fawait`\n- Provide a home for time-based algorithms\n- Be cross-platform and open source\n\n## Motivation\n\n AsyncAlgorithms is a package for algorithms that work with *values over time*. That includes those primarily about *time*, like `debounce` and `throttle`, but also algorithms about *order* like `combineLatest` and `merge`. Operations that work with multiple inputs (like `zip` does on `Sequence`) can be surprisingly complex to implement, with subtle behaviors and many edge cases to consider. A shared package can get these details correct, with extensive testing and documentation, for the benefit of all Swift apps.\n\n The foundation for AsyncAlgorithms was included in Swift 5.5 from [AsyncSequence](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-evolution\u002Fblob\u002Fmain\u002Fproposals\u002F0298-asyncsequence.md). Swift 5.5 also brings the ability to use a natural `for\u002Fin` loop with `await` to process the values in an `AsyncSequence` and `Sequence`-equivalent API like `map` and `filter`. Structured concurrency allows us to write code where intermediate state is simply a local variable, `try` can be used directly on functions that `throw`, and generally treat the logic for asynchronous code similar to that of synchronous code.\n\nThis package is the home for these APIs. Development and API design take place on [GitHub](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms) and the [Swift Forums](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Fswift-async-algorithms).\n\n## Contents\n\n#### Combining asynchronous sequences\n\n- [`chain(_:...)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FChain.md): Concatenates two or more asynchronous sequences with the same element type. \n- [`combineLatest(_:...)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCombineLatest.md): Combines two or more asynchronous sequences into an asynchronous sequence producing a tuple of elements from those base asynchronous sequences that updates when any of the base sequences produce a value.\n- [`merge(_:...)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FMerge.md): Merges two or more asynchronous sequence into a single asynchronous sequence producing the elements of all of the underlying asynchronous sequences.\n- [`zip(_:...)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FZip.md): Creates an asynchronous sequence of pairs built out of underlying asynchronous sequences.\n- [`joined(separator:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FJoined.md): Concatenated elements of an asynchronous sequence of asynchronous sequences, inserting the given separator between each element.\n\n#### Creating asynchronous sequences\n\n- [`async`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FLazy.md): Create an asynchronous sequence composed from a synchronous sequence.\n- [`AsyncChannel`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FChannel.md): An asynchronous sequence with back pressure sending semantics.\n- [`AsyncThrowingChannel`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FChannel.md): An asynchronous sequence with back pressure sending semantics that can emit failures.\n\n#### Performance optimized asynchronous iterators\n\n- [`AsyncBufferedByteIterator`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FBufferedBytes.md): A highly efficient iterator useful for iterating byte sequences derived from asynchronous read functions.\n\n#### Other useful asynchronous sequences\n- [`adjacentPairs()`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FAdjacentPairs.md): Collects tuples of adjacent elements.\n- [`chunks(...)` and `chunked(...)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FChunked.md): Collect values into chunks.\n- [`compacted()`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCompacted.md): Remove nil values from an asynchronous sequence.\n- [`removeDuplicates()`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FRemoveDuplicates.md): Remove sequentially adjacent duplicate values.\n- [`interspersed(with:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FIntersperse.md): Place a value between every two elements of an asynchronous sequence.\n\n#### Asynchronous Sequences that transact in time\n\n- [`debounce(for:tolerance:clock:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FDebounce.md): Emit values after a quiescence period has been reached.\n- [`throttle(for:clock:reducing:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FThrottle.md): Ensure a minimum interval has elapsed between events.\n- [`AsyncTimerSequence`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FTimer.md): Emit the value of now at a given interval repeatedly.\n\n#### Obtaining all values from an asynchronous sequence\n\n- [`RangeReplaceableCollection.init(_:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCollections.md): Creates a new instance of a collection containing the elements of an asynchronous sequence.\n- [`Dictionary.init(uniqueKeysWithValues:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCollections.md): Creates a new dictionary from the key-value pairs in the given asynchronous sequence.\n- [`Dictionary.init(_:uniquingKeysWith:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCollections.md): Creates a new dictionary from the key-value pairs in the given asynchronous sequence, using a combining closure to determine the value for any duplicate keys.\n- [`Dictionary.init(grouping:by:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCollections.md): Creates a new dictionary whose keys are the groupings returned by the given closure and whose values are arrays of the elements that returned each key.\n- [`SetAlgebra.init(_:)`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FCollections.md): Creates a new set from an asynchronous sequence of items.\n\n#### Effects\n\nEach algorithm has specific behavioral effects. For throwing effects these can either be if the sequence throws, does not throw, or rethrows errors. Sendability effects in some asynchronous sequences are conditional whereas others require the composed parts to all be sendable to satisfy a requirement of `Sendable`. The effects are [listed here](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\u002Fblob\u002Fmain\u002FSources\u002FAsyncAlgorithms\u002FAsyncAlgorithms.docc\u002FGuides\u002FEffects.md).\n\n## Adding Swift Async Algorithms as a Dependency\n\nTo use the `AsyncAlgorithms` library in a SwiftPM project, \nadd the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-async-algorithms\", from: \"1.0.0\"),\n```\n\nInclude `\"AsyncAlgorithms\"` as a dependency for your executable target:\n\n```swift\n.target(name: \"\u003Ctarget>\", dependencies: [\n    .product(name: \"AsyncAlgorithms\", package: \"swift-async-algorithms\"),\n]),\n```\n\nFinally, add `import AsyncAlgorithms` to your source code.\n\n## Getting Started\n\n⚠️ Please note that this package requires Xcode 14 on macOS hosts. Previous versions of Xcode do not contain the required Swift version.\n\n### Building\u002FTesting Using Xcode on macOS\n\n  1. In the `swift-async-algorithms` directory run `swift build` or `swift test` accordingly\n\n### Building\u002FTesting on Linux\n\n  1. Download the most recent development toolchain for your Linux distribution\n  2. Decompress the archive to a path in which the `swift` executable is in the binary search path environment variable (`$PATH`)\n  3. In the `swift-async-algorithms` directory run `swift build` or `swift test` accordingly\n\n## Source Stability\n\nThe Swift Async Algorithms package has a goal of being source stable as soon as possible; version numbers will follow [Semantic Versioning](https:\u002F\u002Fsemver.org\u002F). Source breaking changes to public API can only land in a new major version.\n\nThe public API of version 1.0 of the `swift-async-algorithms` package will consist of non-underscored declarations that are marked `public` in the `AsyncAlgorithms` module. Interfaces that aren't part of the public API may continue to change in any release, including patch releases.\n\nFuture minor versions of the package may introduce changes to these rules as needed.\n\nWe'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate. Accordingly, from time to time, we expect that new versions of this package will require clients to upgrade to a more recent Swift toolchain release. Requiring a new Swift release will only require a minor version bump.\n","swift-async-algorithms 是一个为 Swift 语言设计的开源包，提供了异步序列和涉及并发的高级算法。该项目的核心功能包括与 `async\u002Fawait` 的一流集成、提供时间相关的算法（如 debounce 和 throttle）以及跨平台的支持。它还实现了多种操作多个输入流的算法，比如 `combineLatest` 和 `merge`，这些在处理复杂异步逻辑时非常有用。此项目非常适合需要处理随时间变化的数据值的应用场景，特别是那些要求高并发处理能力且注重代码可读性和维护性的 Swift 应用程序开发。通过使用这个库，开发者能够以更自然的方式编写异步代码，同时确保了对各种边缘情况的广泛测试和文档支持。",2,"2026-06-11 03:09:40","top_language"]