{"id":28408878,"url":"https://github.com/inekipelov/swift-result-advance","last_synced_at":"2025-07-29T17:16:51.546Z","repository":{"id":295874770,"uuid":"986860114","full_name":"inekipelov/swift-result-advance","owner":"inekipelov","description":"Collection of extensions for improve Result type","archived":false,"fork":false,"pushed_at":"2025-06-06T11:43:12.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T12:38:10.779Z","etag":null,"topics":["extensions","failure","result","success","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inekipelov.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,"zenodo":null}},"created_at":"2025-05-20T08:20:51.000Z","updated_at":"2025-06-06T11:43:15.000Z","dependencies_parsed_at":"2025-05-27T20:51:05.838Z","dependency_job_id":null,"html_url":"https://github.com/inekipelov/swift-result-advance","commit_stats":null,"previous_names":["inekipelov/swift-result-advance"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/inekipelov/swift-result-advance","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inekipelov%2Fswift-result-advance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inekipelov%2Fswift-result-advance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inekipelov%2Fswift-result-advance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inekipelov%2Fswift-result-advance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inekipelov","download_url":"https://codeload.github.com/inekipelov/swift-result-advance/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inekipelov%2Fswift-result-advance/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261766556,"owners_count":23206645,"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":["extensions","failure","result","success","swift"],"created_at":"2025-06-02T04:37:57.384Z","updated_at":"2025-07-29T17:16:51.529Z","avatar_url":"https://github.com/inekipelov.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResultAdvance\n\n[![Swift Version](https://img.shields.io/badge/Swift-5.5+-orange.svg)](https://swift.org/)\n[![SPM](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Swift Tests](https://github.com/inekipelov/swift-result-advance/actions/workflows/swift.yml/badge.svg)](https://github.com/inekipelov/swift-result-advance/actions/workflows/swift.yml)  \n[![iOS](https://img.shields.io/badge/iOS-13.0+-blue.svg)](https://developer.apple.com/ios/)\n[![macOS](https://img.shields.io/badge/macOS-10.15+-white.svg)](https://developer.apple.com/macos/)\n[![tvOS](https://img.shields.io/badge/tvOS-13.0+-black.svg)](https://developer.apple.com/tvos/)\n[![watchOS](https://img.shields.io/badge/watchOS-6.0+-orange.svg)](https://developer.apple.com/watchos/)\n\nA collection of Swift extensions to improve the `Result` type with additional functionality, providing a more ergonomic API for handling results in Swift applications.\n\n## Features\n\n### Properties\n\n- **`success`**: Gets the success value if available, otherwise returns `nil`\n- **`failure`**: Gets the failure value if available, otherwise returns `nil`\n- **`isSuccess`**: Boolean flag indicating if the result is a success\n- **`isFailure`**: Boolean flag indicating if the result is a failure\n\n### Callbacks\n\n- **`onSuccess(_:)`**: Execute a closure when the result is a success\n- **`onFailure(_:)`**: Execute a closure when the result is a failure\n- **Async variants**: Support for async operations with Task priorities\n\n### Mapping\n\n- **`map(_:)`**: Async-compatible success value mapping\n- **`mapFailure(_:)`**: Async-compatible failure value mapping\n- **`map(success:failure:)`**: Map both success and failure to a common type\n- **Async variants**: Full support for async/await operations\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/inekipelov/swift-result-advance.git\", from: \"0.1.0\")\n]\n```\n\nAnd then add the dependency to your target:\n\n```swift\ntargets: [\n    .target(\n        name: \"YourTarget\",\n        dependencies: [\"ResultAdvance\"]),\n]\n```\n\n## Usage\n\nImport the package in your Swift files:\n\n```swift\nimport ResultAdvance\n```\n\n### Working with Properties\n\nAccess success or failure values directly through properties:\n\n```swift\nlet result: Result\u003cInt, Error\u003e = .success(42)\n\n// Access values directly with properties\nif let value = result.success {\n    print(\"Success value: \\(value)\")\n}\n\nif let error = result.failure {\n    print(\"Error: \\(error)\")\n}\n\n// Check state with boolean properties\nif result.isSuccess {\n    print(\"Operation succeeded\")\n}\n\nif result.isFailure {\n    print(\"Operation failed\")\n}\n```\n\n### Using Callbacks\n\nHandle success and failure cases with chainable callbacks:\n\n```swift\nfetchUserData()\n    .onSuccess { user in\n        // Handle successful user data retrieval\n        updateUI(with: user)\n    }\n    .onFailure { error in\n        // Handle error case\n        showError(error)\n    }\n```\n\n### Async Support\n\n```swift\n// Async callbacks\nfetchUserData()\n    .onSuccess { user in\n        await saveUserToDatabase(user)\n    }\n    .onFailure { error in\n        await logError(error)\n    }\n\n// Async mapping\nlet processedResult = await result.map { value in\n    return await processValue(value)\n}\n```\n\n### Mapping Operations\n\nTransform result values with mapping operations:\n\n```swift\n// Map success values\nlet doubledResult = result.map { value in\n    return value * 2\n}\n\n// Map failure values\nlet mappedErrorResult = result.mapFailure { error in\n    return AppError.mapped(from: error)\n}\n\n// Map to a unified type\nlet finalValue = result.map(\n    success: { value in return \"Success: \\(value)\" },\n    failure: { error in return \"Error: \\(error)\" }\n)\n```\n\n## License\n\nThis project is available under the MIT license. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finekipelov%2Fswift-result-advance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finekipelov%2Fswift-result-advance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finekipelov%2Fswift-result-advance/lists"}