Swiftpack.co -  JonnyGamer/MasterKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
JonnyGamer/MasterKit
A Perfect Swift Framework. All the Extensions.
.package(url: "https://github.com/JonnyGamer/MasterKit.git", from: "0.0.2")

MasterKit

A Perfect Swift Framework. All the Extensions.

MasterKit is a frameowork wrapper.

import MasterKit

When you import it, it automatically imports these packages:

  • ExpressibleEnum
  • ReferenceKit
  • RegexKit

You can also choose to import these packages individually.

ExpressibleEnum

Let's you conform your enums to many new raw value types:

import MasterKit
// or import ExpressibleEnum

// Bool
enum BoolEnum: Bool { 
    case `true` = true
    case `false` = false
}

// Array
case ArrayEnum: [Int] {
    case foo = "[1, 2, 3, 4]"
}

// MultidimensionalArrays
case NDEnum: [[[[[[[[[[Int]]]]]]]]]] {
    case foo = "[[[[[[[[[[0]]]]]]]]]]"
}

// Enum can also conform to Self

// Example 1: Enum A Conforms to A?
enum A: A?, Enum { case foo }
enum B: Self?, Enum { case foo }

// Example 2: Raw Values = Self?
enum C: C?, Enum { case foo = "foo" }
XCTAssert(C.foo == .foo)
XCTAssert(C.foo.rawValue! == .foo)
XCTAssert(C.foo.rawValue!.rawValue! == .foo)
XCTAssert(C.foo == C.foo.rawValue)
XCTAssert(C.foo == C.foo.rawValue?.rawValue?.rawValue?.rawValue)

// Example 3: Oscillating Raw Values
enum D: D?, Enum {
    case bar = "bas"
    case bas = "bar"
}
XCTAssert(D.bar == D.bas.rawValue)
XCTAssert(D.bar != .bar.rawValue!)
XCTAssert(D.bar == .bar.rawValue?.rawValue)

Enums will now be able to conform to:

  • Bool
  • Array (where Element: ExpressibleByStringLiteral)
  • Set (where Element: ExpressibleByStringLiteral)
  • Dictionary<Key, Value> (where Key, Value : ExpressibleByStringLiteral)
  • Range (where Bound: ExpressibleByStringLiteral & AdditiveArithmetic)
  • ClosedRange (where Bound: ExpressibleByStringLiteral & AdditiveArithmetic)
  • Self?, Enum

I've also added protocols to these tpyes, for recursive purposes:

  • extension Array: ExpressibleByStringLiteral where Element: ExpressibleByStringLiteral
  • extension Set: ExpressibleByStringLiteral where Element: ExpressibleByStringLiteral
  • extension Dictionary: ExpressibleByStringLiteral where Key: ExpressibleByStringLiteral, Value: ExpressibleByStringLiteral
  • extension ClosedRange: ExpressibleByStringLiteral where Bound: ExpressibleByStringLiteral
  • extension ClosedRange: Comparable where Bound: AdditiveArithmetic
  • extension ClosedRange: AdditiveArithmetic where Bound: AdditiveArithmetic
  • extension Range: ExpressibleByStringLiteral where Bound: ExpressibleByStringLiteral
  • extension Range: Comparable where Bound: AdditiveArithmetic
  • extension Range: AdditiveArithmetic where Bound: AdditiveArithmetic

ReferenceKit

Create a reference on any Swift value (Even structs!)

import MasterKit
// or import ReferenceKit

func testReference() {
    var foo = 1
    
    @Reference var this = &foo
    this += 1
    
    assert(foo != 1)
    assert(foo == 2)
}

RegexKit

Added a Regex wrapper object. It's totally optional to use, though.

Important Features:

  • matches(String) -> Bool
  • replacingAll(matching: String, with: String) -> String
  • replacingFirst(matching: String, with: String) -> String
  • replacingMiddle(matching: String, with: String) -> String
  • splitMiddle(from: String) -> (String, String)

GitHub

link
Stars: 0
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

0.0.2
4 weeks ago

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