{"id":20348802,"url":"https://github.com/christopherkarani/sukari","last_synced_at":"2025-12-11T22:53:16.375Z","repository":{"id":62456315,"uuid":"114773013","full_name":"christopherkarani/Sukari","owner":"christopherkarani","description":"🍯 Sweet Syntactical Sugar For Swift","archived":false,"fork":false,"pushed_at":"2020-10-20T20:59:52.000Z","size":49,"stargazers_count":30,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-20T13:21:01.824Z","etag":null,"topics":["coregraphics","foundation","swift","syntactic","syntactic-sugar"],"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/christopherkarani.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":"2017-12-19T14:12:10.000Z","updated_at":"2021-11-22T09:21:42.000Z","dependencies_parsed_at":"2022-11-02T00:17:09.128Z","dependency_job_id":null,"html_url":"https://github.com/christopherkarani/Sukari","commit_stats":null,"previous_names":["johnnyMad-Dog/Sukari","johnnymad-dog/sukari","chrisbkarani/sukari"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherkarani%2FSukari","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherkarani%2FSukari/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherkarani%2FSukari/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherkarani%2FSukari/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christopherkarani","download_url":"https://codeload.github.com/christopherkarani/Sukari/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501964,"owners_count":21114714,"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":["coregraphics","foundation","swift","syntactic","syntactic-sugar"],"created_at":"2024-11-14T22:22:27.822Z","updated_at":"2025-12-11T22:53:16.324Z","avatar_url":"https://github.com/christopherkarani.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-Swift4-orange.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://developer.apple.com/ios\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-iOS11-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://https://github.com/lyimin/beautifulApp/blob/develop/LICENSE\"\u003e\u003cimg src=\"http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://twitter.com/xcodedotswift\"\u003e\n\n\u003c/a\u003e\n\u003c/p\u003e\n\n# Sukari\n🍯 Powerful, Elegant Syntactical Sugar for Swift 🍯\n\n\n# Description\n\nEnjoy Beutiful Syntactic Enhancements to your swift code base\n\n## Simply add Sukari to your initializers\n\n#### Use `.this{}` to Initialize Swiftly! 🌈\n\n```swift\n    \n    let fileManager = FileManager().this {\n       $0.urls(for: .applicationDirectory, in: .userDomainMask)\n    }\n    \n```\n    \n#### Clean up your initialization Code! ✨\n    \n```swift\n  let tableView : UITableView = {\n      let table = UITableView()\n      table.backgroundColor = .white\n      table.register(UserCell.self, forCellReuseIdentifier: \"CellID\")\n      table.separatorStyle = .none\n      table.allowsSelection = false\n      return table\n  }()\n```\n\n#### Initialize in **this** way. and and stop repeating yourself! 🚦\n\n```swift\nlet tableView = UITableView().this {\n    $0.backgroundColor = .white\n    $0.register(UserCell.self, forCellReuseIdentifier: \"CellID\")\n    $0.separatorStyle = .none\n    $0.allowsSelection = false\n}\n```\n#### Easily Create and Set Value Types 🛠\n\n```swift\nlet point = CGPoint().set {\n      $0.x = 100\n      $0.y = 200\n }\n```\n\n\n### Add Sugar to your own Types with a little Extension 🔌\n\n```swift\nextension CustomType: Sukari {}\n\nlet instance = CustomType().this {\n      $0.color = .blue\n      $0.label.text = \"Custom Type\"\n }\n```\n### Make your code base a little Sweeter 🍭\n```swift\nclass LoginViewController : UIViewController {\n    var loginButton = UIButton().this {\n        $0.setTitle(\"Login\", for: .normal)\n        $0.backgroundColor = . yellow\n        $0.layer.masksToBounds = true\n        $0.layer.cornerRadius = 5\n    }\n    \n     let emailTextField = UITextField().this {\n        $0.placeholder = \"Email\"\n        $0.borderStyle = .roundedRect\n        $0.font = UIFont.systemFont(ofSize: 14)\n        $0.backgroundColor = UIColor(white: 0, alpha: 0.03)\n    }\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        view.addSubview(loginButton)\n        view.addSubview(emailTextField)\n    }\n}\n\n```\n\n## Unwrap\n\nUnwrap lets you easily require `Optional` values.\n\nUse unwrap() on any optional that you expect to always be non-nil, or else crash your App with a more (optional) descriptive debug message with `.unwrap(debug:)`\n\nOn top of that, unwrap also provides a sytactic enhancement to easily `unwrap` optionals through an under-the-hood `Guard` Statement.\n\n\n1. No More `if` `let` pyramids and `Guard` `let` Towers. only a clean and simple extension to your optionals `unwrap`\n2. Recieve Rich Debug Information with `unwrap(debug:)` ![screen shot 2017-12-19 at 17 35 03](https://user-images.githubusercontent.com/13857475/34170154-dbe22530-e4fa-11e7-89e8-a486eb68648b.png)\n\n#### Adopt this simple but effective enhancment to your code base Now!\n\n\n#### `Guard` `let` tower spotted. \n![screen shot 2017-12-20 at 12 57 13](https://user-images.githubusercontent.com/13857475/34201397-651f73ae-e585-11e7-8d61-f354a1be4e9b.png)\n\n#### Clean, Succinct, and with more descriptive crashes!\n![screen shot 2017-12-20 at 13 03 52](https://user-images.githubusercontent.com/13857475/34201662-4ef9c1aa-e586-11e7-8b1c-fd09908da352.png)\n\n### Usage\n\nCall `unwrap()` on any `Optional`, optionally giving a `debugMessage` for debugging purposes:\n\n```swift\nstruct Person {\n    let name: String\n    let email: String\n    init(dictionary: [String: Any]) {\n        name = dictionary[\"name\"].unwrap(debug: \"Unable to find json Element Name\") as! String\n        email = dictionary[\"email\"].unwrap(debug: \"Unable to find json Element Email\") as! String\n    }\n}\n    let dictionary = [\"ame\": \"Chris\", \"email\": \"chrisbkarani@gmail.com\"]\n    let chris = Person(dictionary: dictionary)\n    print(chris.name) //Chris\n    print(chris.email) // chrisbkarani@gmail.com\n\n```\n\n## Another Real-World Example\n#### Without Using Unwrap\n```swift\nclass LoginController: UIViewController {\n    var token: Token?\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        // more code is more bugs\n        guard let unwrappedToken = token else {\n            // if this crashes we enter a 'nil' state in our app with no debug information\n            return\n        }\n        LoginService.login(unwrappedToken)\n    }\n    \n}\n```\n#### With Unwrap\n\n```swift\nclass LoginController: UIViewController {\n    var token: Token?\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        LoginService.login(token.unwrap())\n    }\n}\n```\n\n\n\n\n### Installing\n\n- **For iOS 8+ projects** with [CocoaPods](https://cocoapods.org):\n    ```ruby\n    pod 'Sukari'\n    ```\n\n\n\n### Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/chrisbkarani/Sugar/blob/master/Contribution.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n\n### Authors\n\n#### Chris Karani\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](https://github.com/chrisbkarani/Sugar/blob/master/LICENSE) file for details\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherkarani%2Fsukari","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristopherkarani%2Fsukari","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherkarani%2Fsukari/lists"}