{"id":13995584,"url":"https://github.com/Flight-School/Rate","last_synced_at":"2025-07-22T22:31:11.158Z","repository":{"id":56407806,"uuid":"142679071","full_name":"Flight-School/Rate","owner":"Flight-School","description":"A type-safe ratio of Foundation unit quantities","archived":true,"fork":false,"pushed_at":"2020-11-09T19:42:44.000Z","size":25,"stargazers_count":68,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-25T18:26:53.984Z","etag":null,"topics":["conversion","dimensional-analysis","foundation","measurements","numbers","rate","swift","units"],"latest_commit_sha":null,"homepage":"https://flight.school/books/numbers","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/Flight-School.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["mattt"],"custom":"https://flight.school/books/numbers"}},"created_at":"2018-07-28T13:22:27.000Z","updated_at":"2024-10-19T11:49:17.000Z","dependencies_parsed_at":"2022-08-15T18:10:27.463Z","dependency_job_id":null,"html_url":"https://github.com/Flight-School/Rate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Flight-School/Rate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2FRate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2FRate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2FRate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2FRate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flight-School","download_url":"https://codeload.github.com/Flight-School/Rate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flight-School%2FRate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266585709,"owners_count":23952163,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["conversion","dimensional-analysis","foundation","measurements","numbers","rate","swift","units"],"created_at":"2024-08-09T14:03:29.758Z","updated_at":"2025-07-22T22:31:10.875Z","avatar_url":"https://github.com/Flight-School.png","language":"Swift","funding_links":["https://github.com/sponsors/mattt","https://flight.school/books/numbers"],"categories":["Swift"],"sub_categories":[],"readme":"# Rate\n\n[![Build Status][build status badge]][build status]\n\nA ratio of two related quantities,\nexpressed in terms of an amount of numerator unit per single denominator unit.\n\nThis functionality is discussed in Chapter 5 of\n[Flight School Guide to Swift Numbers](https://flight.school/books/numbers).\n\n## Requirements\n\n- Swift 4.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd the Rate package to your target dependencies in `Package.swift`:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n  name: \"YourProject\",\n  dependencies: [\n    .package(\n        url: \"https://github.com/Flight-School/Rate\",\n        from: \"1.0.0\"\n    ),\n  ]\n)\n```\n\nThen run the `swift build` command to build your project.\n\n### Carthage\n\nTo use Rate in your Xcode project using Carthage,\nspecify it in `Cartfile`:\n\n```\ngithub \"Flight-School/Rate\" ~\u003e 1.0.0\n```\n\nThen run the `carthage update` command to build the framework,\nand drag the built Rate.framework into your Xcode project.\n\n## Usage\n\nOne of the shortcomings of the Foundation Unit and Measurement APIs\nis the inability to dynamically declare compound units.\nThis can make it difficult to perform dimensional analysis\nand other multi-step calculations.\n\nThe `Rate` structure allows you to express the ratio\nbetween two units in a type-safe manner.\nMultiplying a measurement with one unit type by a rate\nwhose denominator is that same unit type causes those types to cancel out,\nresulting in a measurement with the numerator type.\n\nFor example, volume over time multiplied by time yields volume:\n\n```swift\nlet flowRate = Rate\u003cUnitVolume, UnitDuration\u003e(value: 84760,\n                                               unit: .cubicFeet,\n                                                per: .seconds)\nlet oneDay = Measurement\u003cUnitDuration\u003e(value: 24, unit: .hours)\n\n(flowRate * oneDay).converted(to: .megaliters) // 207371ML\n```\n\n## License\n\nMIT\n\n## Contact\n\nMattt ([@mattt](https://twitter.com/mattt))\n\n[build status]: https://github.com/Flight-School/Rate/actions?query=workflow%3ACI\n[build status badge]: https://github.com/Flight-School/Rate/workflows/CI/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlight-School%2FRate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFlight-School%2FRate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlight-School%2FRate/lists"}