{"id":22279225,"url":"https://github.com/flowductive/foundation-plus","last_synced_at":"2025-07-28T18:31:31.946Z","repository":{"id":37245281,"uuid":"428457633","full_name":"Flowductive/foundation-plus","owner":"Flowductive","description":"🧱 Swift Foundation tools to make your life a little easier. Includes extensions for Array, String, Date, TimeInterval, Optional, and more.","archived":false,"fork":false,"pushed_at":"2024-01-22T20:09:24.000Z","size":996,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-01-22T23:31:30.369Z","etag":null,"topics":["foundation","ios","macos","swift","swift-package","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flowductive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-11-15T23:51:31.000Z","updated_at":"2023-11-15T22:21:03.000Z","dependencies_parsed_at":"2024-01-22T21:29:49.157Z","dependency_job_id":"c0b037d3-3f55-46ee-9f45-598ee6f03023","html_url":"https://github.com/Flowductive/foundation-plus","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowductive%2Ffoundation-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowductive%2Ffoundation-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowductive%2Ffoundation-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowductive%2Ffoundation-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flowductive","download_url":"https://codeload.github.com/Flowductive/foundation-plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227941948,"owners_count":17844685,"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":["foundation","ios","macos","swift","swift-package","swift-package-manager"],"created_at":"2024-12-03T15:18:39.414Z","updated_at":"2024-12-03T15:18:39.960Z","avatar_url":"https://github.com/Flowductive.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Social Preview](./Assets/Social%20Preview%20(640).png)\n\n\u003ch2 align=\"center\"\u003eBasic Swift extensions that make life easier.\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e🪶 Lightweight, Swift-y looking code for modern SwiftUI developers\u003c/p\u003e\n\u003cp align=\"center\"\u003e🧩 Useful methods and properties written in native Swift\u003c/p\u003e\n\n***\n\n⚠️ **Note:** This package is still under development and its contents are freely subject to change.\n\n🚧 **Wiki under construction.** Read below to get started!\n\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Flowductive/foundation-plus?label=version)\n![GitHub Release Date](https://img.shields.io/github/release-date/Flowductive/foundation-plus?label=latest%20release)\n![GitHub issues](https://img.shields.io/github/issues/Flowductive/foundation-plus)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/Flowductive/foundation-plus)\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFlowductive%2Feasy-firebase%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/Flowductive/foundation-plus)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFlowductive%2Feasy-firebase%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/Flowductive/foundation-plus)\n\n## What is FoundationPlus?\n\nFoundationPlus is a suite of basic Swift extensions that help speed up the process of app development, and help make your code look nicer. Functions that you'll normally need, like methods to check the app's version, get the current day of week, and so on, can have convoluted code. FoundationPlus simplifies these with built-in extensions.\n\n```swift\n// 😴 Before\nlet interval = TimeInterval(9945)\n\n// ✨ After\nlet interval = 2.hours + 45.minutes + 45.seconds\n```\n\n```swift\n// 😴 Before\nif let value = optionalValue {\n  myVar = value\n} else {\n  myVar = nil\n}\n\n// ✨ After\nmyVar =? optionalValue\n```\n\n```swift\n// 😴 Before\nif array.count \u003e= 5 {\n  myVar = array[4]\n}\n\n// ✨ After\nmyVar = array[safe: 4]\n```\n\n## Completed Features\n\n- Extensions\n  - Date and TimeInterval extensions [→](https://github.com/Flowductive/foundation-plus#date-and-timeinterval-extensions)\n  - Array extensions [→](https://github.com/Flowductive/foundation-plus#array-extensions)\n  - Optional extensions [→](https://github.com/Flowductive/foundation-plus#optional-extensions)\n  - String extensions [→](https://github.com/Flowductive/foundation-plus#string-extensions)\n- Other Features\n  - Open URL action [→](https://github.com/Flowductive/foundation-plus#open-url-action)\n  - Get part of day and weekday [→](https://github.com/Flowductive/foundation-plus#get-part-of-day-and-weekday)\n\nMost of the above features are **cross-platform** and are supported on iOS, macOS, tvOS and watchOS.\n\n## Get Started\n\nAdd **FoundationPlus** to your project using Swift Package Manager:\n\n```\nhttps://github.com/Flowductive/foundation-plus\n```\n\n## 🧩 Extensions\n\n### Date and TimeInterval extensions\n\nGet `TimeIntervals` easily:\n\n```swift\nlet interval = 10.minutes\nlet interval2 = 4.days\n```\n\nFormat `TimeInterval`s:\n\n```swift\nprint(3.hours.formattedColon) // 3:00\nprint((2.minutes + 30.seconds).formatted(.short)) // 2m 30s\nprint(4.hours.formatted(.full)) // 4 hours\n```\n\nGet the current month, day, hour, minute, etc:\n\n```swift\nlet date = Date()\nlet dateFormatted = \"The current time is \\(date.hour) : \\(date.minute).\"\n```\n\nGet a date moved forward to right before midnight:\n\n```swift\nlet thisEvening = date.atMidnight\n```\n\nGet formatted versions of the date:\n\n```swift\nprint(date.shorthand) // 6/7/22\nprint(date.longhand) // Tuesday, June 07, 2022\n```\n\nSubtract dates and get a `TimeInterval`:\n\n```swift\nlet timeBetween = laterDate - earlierDate\n```\n\nGet the next/preview occurence of a specific weekday:\n\n```swift\nlet nextTuesday = Date().next(.tuesday)\nlet lastWednesday = Date().previous(.wednesday, considerToday: false)\n```\n\nGet a string representing how long it's been since the `Date`:\n\n```swift\nprint(lastWednesday.timeAgoSince()) // 2 days ago\n```\n\n### Array extensions\n\nSafely subscript arrays, and even wrap array indices:\n\n```swift\nlet myString = [\"a\", \"b\", \"c\", \"d\"]\nlet myString: String = myStrings[safe: 5] ?? \"-\" // \"-\"\nlet myString2: String = myString[wrap: 5] // \"b\"\n```\n\nUse new operators on arrays:\n\n```swift\nvar array: [1, 2, 3]\n\n// Add the element(s) if it is not inside\narray \u003c= 4 // [1, 2, 3, 4]\narray \u003c= 2 // [1, 2, 3, 4]\narray \u003c= [4, 5] // [1, 2, 3, 4, 5]\n\n// Remove elements\narray -= 1 // [2, 3, 4, 5]\narray -= [2, 3, 6] // [4, 5]\n```\n\nUse additional methods on arrays:\n\n```swift\nlet array = [1, 2, 3, 3]\n// Add to the end if not already in the array\narray.appendUniquely(5) // [1, 2, 3, 3, 5]\n// Add to the beginning if not already in the array\narray.pushUniquely(0) // [0, 1, 2, 3, 3, 5]\n// Remove all of an element\narray.removeAll(3) // [0, 1, 2, 5]\n// Pick a random bunch of elements\narray.pick(2) // [0, 2]\n```\n\n### Optional extensions\n\nOptionally assign the right-hand side to the left-hand side if non-`nil`:\n\n```swift\nvar str: String = \"Hello World\"\nvar optionalStr: String? = nil\nstr =? optionalStr // Only sets str if myOptionalString is non-nil\nprint(str) // \"Hello, world\"\n```\n\nOptionally check if two `Optional` or non-`Optional` values are equal/nonequal, and return `false` for equality and `true` for inequality if either value is `nil`:\n\n```swift\nlet areEqual: Bool { nil ==? 4 } // False\nlet areNonEqual: Bool { 4 !=? 3 } // True\n```\n\n### String extensions\n\nReturn only alpha-numeric parts of a String:\n\n```swift\nlet alphanumeric = \"Abc123+-=~\".alphanumeric // \"Abc123\"\n```\n\nReturn the first word of a String:\n\n```swift\nlet first = \"Hello World!\".firstWord // \"Hello\"\n```\n\nGet a random alphanumeric string with a specified length:\n\n```swift\nlet random = String.random(16) // \"b7vb92Fg9FEN2g8A\"\n```\n\nRepeat a String:\n\n```swift\nlet repeated = \"Hi\".repeat(5) // \"HiHiHiHiHi\"\n```\n\nCheck if a String is a valid email:\n\n```swift\nlet isEmailValid: Bool = \"test@hi.com\".isValidEmail() // True\n```\n\n## ✨ Other Features\n\n### Get URL action\n\nQuickly open a URL in iOS or macOS:\n\n```swift\nmyUrl.open()\n```\n\n### Get part of day and weekday\n\nGrab information regarding the time of day:\n\n```swift\nlet part = DayPart.get(from: Date()) // Chooses automatically from .morning, .midday, .afternoon, .evening, .night, and .midnight\nprint(part.greeting) // \"Good morning!\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowductive%2Ffoundation-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflowductive%2Ffoundation-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowductive%2Ffoundation-plus/lists"}