{"id":16322241,"url":"https://github.com/p-x9/keypathvalue","last_synced_at":"2025-10-25T19:31:26.241Z","repository":{"id":63187722,"uuid":"565848135","full_name":"p-x9/KeyPathValue","owner":"p-x9","description":"🔑 Structure for assigning values using keypath","archived":false,"fork":false,"pushed_at":"2024-04-01T14:25:22.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-08T04:31:09.343Z","etag":null,"topics":["swift","swiftpackage"],"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/p-x9.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}},"created_at":"2022-11-14T13:06:16.000Z","updated_at":"2023-06-14T00:17:21.000Z","dependencies_parsed_at":"2023-02-09T20:15:15.284Z","dependency_job_id":null,"html_url":"https://github.com/p-x9/KeyPathValue","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FKeyPathValue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FKeyPathValue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FKeyPathValue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FKeyPathValue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-x9","download_url":"https://codeload.github.com/p-x9/KeyPathValue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865105,"owners_count":16555931,"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":["swift","swiftpackage"],"created_at":"2024-10-10T22:50:21.643Z","updated_at":"2025-10-25T19:31:25.957Z","avatar_url":"https://github.com/p-x9.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KeyPathValue\nStructure for assigning values using keypath\n\n## Example\n### ReferenceWritableKeyPathValueApplier\nSuppose we have the following model.\n```swift\nstruct CALayerModel {\n    var bounds: CGRect?\n    var position: CGPoint?\n    var frame: CGRect?\n\n    var backgroundColor: CGColor?\n\n    var cornerRadius: CGFloat?\n\n    var borderWidth: CGFloat?\n    var borderColor: CGColor?\n}\n```\nDefine propertyMap using `ReferenceWritableKeyPathValueApplier`\n\n```swift\nlet propertyMap: [PartialKeyPath\u003cCALayerModel\u003e: ReferenceWritableKeyPathValueApplier\u003cCALayer\u003e] = [\n        \\.bounds: .init(\\.bounds),\n         \\.position: .init(\\.position),\n         \\.frame: .init(\\.frame),\n         \\.backgroundColor: .init(\\.backgroundColor),\n         \\.cornerRadius: .init(\\.cornerRadius),\n         \\.borderWidth: .init(\\.borderWidth),\n         \\.borderColor: .init(\\.borderColor)\n    ]\n```\nCan be assigned to an object using propertyMap.\n```swift\nextension CALayerModel {\n    public func applyProperties(to target: CALayer) {\n        Self.propertyMap.forEach { keyPath, applier in\n            let value = self[keyPath: keyPath]\n            applier.apply(value, target)\n        }\n    }\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Fkeypathvalue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-x9%2Fkeypathvalue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Fkeypathvalue/lists"}