Swiftpack.co - wookiee/Convenience as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by wookiee.
wookiee/Convenience 0.3.3
A small pile of Swift extensions and conveniences I tend to add to personal projects.
⭐️ 0
🕓 1 year ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/wookiee/Convenience.git", from: "0.3.3")

Unlicense Swift 5.4

Convenience

This is a little holding place for common tools and conveniences that I like to use in my personal projects.

If anyone ever finds and uses this, I'd love to hear any feedback.

Contents:

  • Extensions:
    • OSLog.Logger:
      • init(_:), which uses the process name and bundle name for the logger's subsystem, and the provided string for the category.
    • Int:
      • of<Value>(_ value: @autoclosure () throws -> Value) rethrows -> [Value]): fills an array with self values by executing the provided closure self times.
      • times(_ execute: @autoclosure () throws -> Void) rethrows: executes the provided closure self times.
    • String:
      • randomTitle(wordCount:): generates a randomized Title Case string a specified number of words long.
    • Calendar:
      • days(from:to:): computes a distance, in days, between two dates. Accounts for partial days.
      • cardinalComponents(from:to:) computes a distance, in years, months, and days, between two dates. Accounts for partial days.
    • Result: *static func success(): a wrapper for the uglier .success(())
  • Tools:
    • Keychain: A simplistic wrapper for storing single String values into the user's keychain. Uses the kSecClassGenericPassword item class.
  • Property wrappers:
    • KeychainStorage: A property wrapper that uses the Keychain convenience to wrap properties that use the user's keychain for their storage.
    • ReadersWriterLocked: A property wrapper for making values thread-safe for access using a queue-based readers-writer lock.
    • UserDefault: A property wrapper that uses UserDefaults for storage. Requires that the property's type is Optional and Codable.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics