{"id":17295206,"url":"https://github.com/adam-fowler/async-collections","last_synced_at":"2025-04-14T11:30:39.500Z","repository":{"id":109173724,"uuid":"428046425","full_name":"adam-fowler/async-collections","owner":"adam-fowler","description":"Swift concurrency collection support","archived":false,"fork":false,"pushed_at":"2024-04-29T14:53:25.000Z","size":33,"stargazers_count":35,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T20:49:54.721Z","etag":null,"topics":["async-await","collections","concurrency","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adam-fowler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-14T21:33:05.000Z","updated_at":"2025-04-01T08:46:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"67b02df1-d088-4926-8206-ed546a67894c","html_url":"https://github.com/adam-fowler/async-collections","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-fowler%2Fasync-collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-fowler%2Fasync-collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-fowler%2Fasync-collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-fowler%2Fasync-collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adam-fowler","download_url":"https://codeload.github.com/adam-fowler/async-collections/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248871640,"owners_count":21175265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-await","collections","concurrency","swift"],"created_at":"2024-10-15T11:09:42.964Z","updated_at":"2025-04-14T11:30:39.478Z","avatar_url":"https://github.com/adam-fowler.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AsyncCollections\n\nFunctions for running async processes on Swift Collections\n\n## ForEach\n\nRun an async function on every element of a Sequence.\n```swift\nawait array.asyncForEach {\n    await asyncProcess($0)\n}\n```\nThe async closures are run serially ie the closure run on the current element of a sequence has to finish before we run the closure on the next element.\n\nTo run the closures concurrently use\n```swift\ntry await array.concurrentForEach {\n    try await asyncProcess($0)\n}\n```\nYou can manage the number of tasks running at any one time with the `maxConcurrentTasks` parameter\n```swift\ntry await array.concurrentForEach(maxConcurrentTasks: 4) {\n    try await asyncProcess($0)\n}\n```\n\n## Map\n\nReturn an array transformed by an async function.\n```swift\nlet result = await array.asyncMap {\n    return await asyncTransform($0)\n}\n```\n\nSimilar to `asyncForEach` there are versions of `asyncMap` that runs the transforms concurrently.\n\n```swift\nlet result = await array.concurrentMap(maxConcurrentTasks: 8) {\n    return await asyncTransform($0)\n}\n```\n\n## Compact Map\n\nReturn a non-optional array transformed by an async function returning optional results.\n```swift\nlet result: [MyType] = await array.asyncCompactMap { value -\u003e MyType? in\n    return await asyncTransform(value)\n}\n```\n\nSimilar to `asyncForEach` there are versions of `asyncCompactMap` that runs the transforms concurrently.\n\n```swift\nlet result: [MyType] = await array.concurrentCompactMap(maxConcurrentTasks: 8) { value -\u003e MyType? in\n    return await asyncTransform(value)\n```\n\n## FlatMap\n\nReturn a concatenated array transformed by an async function that returns a sequence.\n```swift\nlet result: [MySequence.Element] = await array.asyncMap { value -\u003e MySequence in\n    return await asyncTransform($0)\n}\n```\n\nSimilar to `asyncForEach` there are versions of `asyncFlatMap` that runs the transforms concurrently.\n\n```swift\nlet result: [MySequence.Element] = await array.concurrentMap(maxConcurrentTasks: 8) { value -\u003e MySequence in\n    return await asyncTransform($0)\n}\n```\n\n## Filter\n\nReturn a filtered array transformed by an async function.\n```swift\nlet result = await array.asyncFilter {\n    return await asyncTransform($0)\n}\n```\n\nSimilar to `asyncForEach` there are versions of `asyncFilter` that runs the transforms concurrently.\n\n```swift\nlet result = await array.concurrentFilter(maxConcurrentTasks: 8) {\n    return await asyncTransform($0)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-fowler%2Fasync-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadam-fowler%2Fasync-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-fowler%2Fasync-collections/lists"}