Hi everyone,
I'd like to share AsyncCollections - a lightweight package that adds async and concurrent higher-order functions to Swift's Sequence type.
Motivation
Running async work over a regular Array typically means writing manual TaskGroup boilerplate to handle concurrency, preserve order, and limit parallelism. AsyncCollections wraps that into familiar one liners:
// Sequential - one at a time
let data = try await urls.asyncMap { try await fetch($0) }
// Concurrent - all in parallel, order preserved
let images = try await urls.concurrentMap { try await downloadImage($0) }
// Throttled parallelism
let results = try await urls.concurrentMap(maxNumberOfTasks: 5) { try await process($0) }
API surface: asyncMap, asyncCompactMap, asyncFlatMap, asyncForEach, asyncFilter, asyncReduce and concurrent variants of each with optional maxNumberOfTasks.
How it differs from swift-async-algorithms
Apple's package operates on AsyncSequence - values arriving over time (streams, debounce, throttle). AsyncCollections operates on regular Sequence types you already have in hand. They're complementary, not competing.
Details: Swift 6 strict concurrency compatible, order-preserving, automatic cancellation propagation via TaskGroup, zero dependencies.
Repo: GitHub - serhanaksut/swift-async-collections
Feedback and contributions are welcome!