{"id":15293568,"url":"https://github.com/khoi-backyard/swiftlyext","last_synced_at":"2025-04-13T14:07:26.703Z","repository":{"id":62456838,"uuid":"68696494","full_name":"khoi-backyard/SwiftlyExt","owner":"khoi-backyard","description":"SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀","archived":false,"fork":false,"pushed_at":"2017-03-15T07:36:20.000Z","size":133,"stargazers_count":31,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:07:23.501Z","etag":null,"topics":["carthage","cocoadocs","cocoapods","extension","extensions","functional","functional-programming","swift","swift-3","swift-framework","swift-library","swift-package-manager","swift3","xcode"],"latest_commit_sha":null,"homepage":"http://cocoadocs.org/docsets/SwiftlyExt/","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/khoi-backyard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-09-20T09:29:44.000Z","updated_at":"2019-10-29T08:43:54.000Z","dependencies_parsed_at":"2022-11-02T00:15:20.326Z","dependency_job_id":null,"html_url":"https://github.com/khoi-backyard/SwiftlyExt","commit_stats":null,"previous_names":["khoiln/swiftly","khoiln/swiftlyext"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khoi-backyard%2FSwiftlyExt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khoi-backyard%2FSwiftlyExt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khoi-backyard%2FSwiftlyExt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khoi-backyard%2FSwiftlyExt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khoi-backyard","download_url":"https://codeload.github.com/khoi-backyard/SwiftlyExt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724637,"owners_count":21151561,"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":["carthage","cocoadocs","cocoapods","extension","extensions","functional","functional-programming","swift","swift-3","swift-framework","swift-library","swift-package-manager","swift3","xcode"],"created_at":"2024-09-30T16:50:01.098Z","updated_at":"2025-04-13T14:07:26.670Z","avatar_url":"https://github.com/khoi-backyard.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](Logo/logo.png)\n\n[![Build Status](https://travis-ci.org/khoiln/SwiftlyExt.svg?branch=master)](https://travis-ci.org/khoiln/SwiftlyExt)\n[![codecov](https://codecov.io/gh/khoiln/SwiftlyExt/branch/master/graph/badge.svg)](https://codecov.io/gh/khoiln/SwiftlyExt)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftlyExt.svg)](https://img.shields.io/cocoapods/v/SwiftlyExt.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftlyExt.svg?style=flat)](http://cocoadocs.org/docsets/SwiftlyExt)\n[![MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)\n\nSwiftlyExt is a library that extends certain Swift standard types and classes using extension feature in the Swift language.\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Documentation via CocoaDocs](http://cocoadocs.org/docsets/SwiftlyExt/)\n- [FAQ](#faq)\n- [License](#license)\n\n## Requirements\n\n- iOS 9.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+\n- Xcode 8.0+\n- Swift 3.0+\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.1.0+ is required to build SwiftlyExt.\n\nTo integrate SwiftlyExt into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'SwiftlyExt', '~\u003e 1.3'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate SwiftlyExt into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"khoiln/SwiftlyExt\" ~\u003e 1.3\n```\n\nRun `carthage update` to build the framework and drag the built `SwiftlyExt.framework` into your Xcode project. U\n\n### Swift Package Manager\n\nAdding SwiftlyExt as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift` file.\n\n```swift\ndependencies: [\n    .Package(url: \"https://github.com/khoiln/SwiftlyExt.git\", majorVersion: 1)\n]\n```\n\nNote that the [Swift Package Manager](https://swift.org/package-manager/) is still in early design and development, but SwiftlyExt does support its use on supported platforms.\n\n## Usage\n\nThere are many handy usages of `SwiftlyExt`, head over [CocoaDocs](http://cocoadocs.org/docsets/SwiftlyExt/) for the comprehensive documentation.\n\nWe'll try to list some of the cool examples here.\n\n### Array Extensions\n\n```swift\n[😀,🤡,❤️,💋].sample() // Return a random element\n// =\u003e 💋\n[😀,🤡,❤️,💋].sampleSize(2) // Return n random elements\n// =\u003e [🤡, 💋]\n[1, 2, 3, 4, 5].dropWhile { $0 \u003c 3 } //Drop elements that passes the predicate from the beginning to end\n// =\u003e [3, 4, 5]\n[1, 2, 3, 4, 5].dropWhile { $0 \u003c 3 }.some {$0 % 2 == 0} //And YES you can use method chaining too 👍\n// =\u003e true\n[0, 11, 28, 10].every { $0 % 2 == 0 } //Check if all elements in the array passed the condition\n// =\u003e false\n[0, 11, 28, 10].some { $0 % 2 != 0 } //Check if one of the element passes the condition\n// =\u003e true\n[1, 2, 3, 4, 5].findLastIndex {$0 % 2 == 0} //Find index of the last number which predicate return true for.\n// =\u003e 3 \n[1, 2, 3, 4, 5].groupBy { $0 % 2 == 0 ? \"even\" : \"odd\"} //Group common elements from an array to a dictionary of [Hashable : [Element]]\n// =\u003e [\"even\": [2,4], \"odd\": [1,3,5]]\n// Any many more....\n```\n\n### Date Extensions\n\n```swift\nlet now = Date()\nlet tmr = now.date(byAddingDays: 1)\n             .date(byAddingMinutes: 20) // You could also add year, month... and other time units\n\nnow.isBefore(tmr) \n// =\u003e true\n\nnow?.toString(format: \"dd/MM/yyyy HH:mm:ss\") // Return the string representation for a date.\n// =\u003e \"03/15/2017 14:34:22\"\n\ntmr.year == 2017 // Access time unit properties\ntmr.hour == 14\ntmr.minute == 54\n```\n\n### String Extensions\n\n```swift\n\"John Doe\".initials // Return the initials of the String\n// =\u003e \"JD\"\n\"swift@swiftly.com\".isEmail // Email validation\n// =\u003e true\n\"\u003cp\u003e💯\u003c/p\u003e\".between(\"\u003cp\u003e\", \"\u003c/p\u003e\") // Find the string between two string\n// =\u003e \"💯\" \n\"01/01/1970 00:34:22\".date(format: \"dd/MM/yyyy HH:mm:ss\") // Return a date from current string\n// =\u003e Date(\"01/01/1970 00:34:22\")\n\"https://github.com/Swiftly\".base64Encoded // Return base64encoded string\n// =\u003e \"aHR0cHM6Ly9naXRodWIuY29tL1N3aWZ0bHk=\"\n\"\\n\\n\\n Swiftly    \".trimmed.reversed // Trim newline and spaces and reverse the string\n// =\u003e \"yltfiwS\"\n\"Swiftly\\t\\nString\\nTest\".urlEncoded // URL Encoded\n// =\u003e \"Swiftly%09%0AString%0ATest\"\n\"https%3A%2F%2Fgithub.com%2Fkhoiln%2FSwiftlyEXT\".urlDecoded // URL Decoded\n// =\u003e \"https://github.com/khoiln/SwiftlyEXT\"\n// Any many more....\n```\n\n### Int Extensions\n\n```swift\n1.upTo(3) { print($0) } \n// print 1, 2, 3\n5.times { print(\"🐶\") } // Run a block n times\n// print 🐶 5 times\n1234.digits() // Convert integer to array of digits\n// =\u003e [1,2,3,4]\n201.isIn(range: 200..\u003c300) // Test whether a int is in a range\n// =\u003e true\n// And many more\n```\n\n## How to contribute\nAny help or feedback is highly appreciated. Please refer to the [contributing guidelines](https://github.com/khoiln/SwiftlyExt/blob/master/CONTRIBUTING.md) for more information.\n\n## License\n\nSwiftyExt is released under the MIT license. See [LICENSE](https://github.com/khoiln/SwiftlyExt/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhoi-backyard%2Fswiftlyext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhoi-backyard%2Fswiftlyext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhoi-backyard%2Fswiftlyext/lists"}