A simple composition framework to create transformations that are either unidirectional or bidirectional

Overview

c

Micro Composition

What is c?

c is a simple composition framework. You have the ability to create transformations that are either unidirectional or bidirectional. There is also a cache that values can be set and resolved.

Where can c be used?

c can be used anywhere to create transformations or interact with the cache.

Examples

BiDirectionalTransformation of String and Int

let transformer = c.transformer(
    from: { string in Int(string) },
    to: { int in "\(String(describing: int))" }
)

let string = transformer.to(3)
let int = transformer.from("3")

try t.assert(transformer.to(int), isEqualTo: string)

Cache

c.set(value: Double.pi, forKey: "🥧")

let pi: Double = c.get("🥧") ?? 0

try t.assert(pi, isEqualTo: .pi)

let resolvedValue: Double = c.resolve("🥧")

try t.assert(resolvedValue, isEqualTo: .pi)
You might also like...
ConfettiKit is a custom framework used to add Confetti on your iOS/iPadOS projects.
ConfettiKit is a custom framework used to add Confetti on your iOS/iPadOS projects.

ConfettiKit is a custom framework used to add Confetti on your iOS/iPadOS projects. The kit provides variety of customisations inorder to design a confetti which matches your project's UI. ConfettiKit makes your work of adding Confetti on your project with just one line of code.

A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework.
A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework.

macOS Virtual Machine A ARM macOS Virtual Machine, using macOS 12's new Virtualization framework. I copied KhaosT's code from here, all I did is chang

Alchemy, an elegant, batteries included backend framework for Swift.
Alchemy, an elegant, batteries included backend framework for Swift.

Elegant, batteries included web framework for Swift.

SandboxKit - Framework that makes it easy to launch a single Scene of your application

SandboxKit This framework makes debugging more efficient in your application. Sandbox is the name of a structure that improves the efficiency of debug

The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.
The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

QuoteKit The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey. It uses the latest async/await syntax for

contoh pembuatan framework untuk ios swift

circularContohFramework Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Install

Useless tools for exploring Virtualization.framework

Tools for exploring the internals of Virtualization.framework's Mac virtualization support. I made this since I don't have an Apple Silicon Mac but st

A Swift SPM framework for running and managing Lua code from Swift

LuaKit A Swift Package for running and managing Lua code from Swift. Documentation For documentation, add this package as Swift Package Dependency, an

Generic model framework

Pistachio Pistachio is a generic model framework. By leveraging lenses and value transformers, it allows you to create type safe adapters for any recu

Releases(3.0.0)
  • 3.0.0(Oct 23, 2022)

    What's Changed

    • Added InvalidTypeError
    • Removed force unwraps for throwing
    • Changed JSON to a struct and removed conformance to Cacheable

    Full Changelog: https://github.com/0xOpenBytes/c/compare/2.0.0...3.0.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Oct 21, 2022)

    c

    Micro Composition

    What is c?

    c is a simple composition framework. You have the ability to create transformations that are either unidirectional or bidirectional. There is also a cache that values can be set and resolved.

    Where can c be used?

    c can be used anywhere to create transformations or interact with the cache.

    Examples

    BiDirectionalTransformation of String and Int

    let transformer = c.transformer(
        from: { string in Int(string) },
        to: { int in "\(String(describing: int))" }
    )
    
    let string = transformer.to(3)
    let int = transformer.from("3")
    
    try t.assert(transformer.to(int), isEqualTo: string)
    

    Cache

    let cache = c.Cache()
    
    cache.set(value: Double.pi, forKey: "🥧")
    
    let pi: Double = cache.get("🥧") ?? 0
    
    try t.assert(pi, isEqualTo: .pi)
    
    let resolvedValue: Double = try cache.resolve("🥧")
    
    try t.assert(resolvedValue, isEqualTo: .pi)
                        
    cache.remove("🥧")
    
    let nilValue: Double? = cache.get("🥧")
    
    try t.assert(isNil: nilValue)
    

    KeyedCache

    enum CacheKey: Hashable { ... }
    
    let cache = c.KeyedCache<CacheKey>()
    
    cache.set(value: Double.pi, forKey: CacheKey.piKey)
    
    let pi: Double = cache.get(.piKey) ?? 0
    
    try t.assert(pi, isEqualTo: .pi)
    
    let resolvedValue: Double = try cache.resolve(.piKey)
    
    try t.assert(resolvedValue, isEqualTo: .pi)
                        
    cache.remove(.piKey)
    
    let nilValue: Double? = cache.get(.piKey)
    
    try t.assert(isNil: nilValue)
    

    JSON

    enum MockJSONKey: String, Hashable {
        case name, number, bool, invalid_key
    }
    
    struct MockJSON: Codable {
        var name: String
        var number: Int
        var bool: Bool
    }
    
    let jsonData: Data = try! JSONEncoder().encode(MockJSON(name: "Twitch", number: 5, bool: false))
    
    let json: c.JSON<MockJSONKey> = .init(data: jsonData)
    
    XCTAssertEqual(try! json.resolve(.name), "Twitch")
    XCTAssertEqual(try! json.resolve(.number), 5)
    XCTAssertEqual(try! json.resolve(.bool), false)
    
    let invalid_key: Bool? = json.get(.invalid_key)
    
    XCTAssertNil(json.get(.invalid_key))
    XCTAssertNil(invalid_key)
    
    json.set(value: "Leif", forKey: .name)
    
    XCTAssertEqual(try! json.resolve(.name), "Leif")
    

    Global Cache

    let someCache: Cache = ...
    
    // Set the value of a Cache with any hashable key
    c.set(value: someCache, forKey: "someCache")
    
    // Get an optional Cache using any hashable key
    let anotherCache: Cache? = c.get(0)
    
    // Require that a Cache exist using a `.get` with a force unwrap
    let requiredCache: Cache = try c.resolve(0)
    
    let keyedCache: KeyedCache<String> = try c.resolve(...)
    

    Changes: https://github.com/0xOpenBytes/c/commit/1a211c68ce509f77f789440ba008e7ad2898dac1

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Oct 19, 2022)

    What's Changed

    • Support sub JSON Arrays by @0xLeif in https://github.com/0xOpenBytes/c/pull/6

    Full Changelog: https://github.com/0xOpenBytes/c/compare/1.1.1...1.2.0

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(May 17, 2022)

    Fixed

    • Access type for MissingRequiredKeysError init

    Added

    • contains: Checks if the given key has a value or not
    • require: Checks to make sure the cache has the required keys, otherwise it will throw an error
    • valuesInCache: Returns a Dictionary containing only the key value pairs where the value is the same type as the generic type Value

    What's Changed

    • Develop by @0xLeif in https://github.com/0xOpenBytes/c/pull/5

    Full Changelog: https://github.com/0xOpenBytes/c/compare/1.1.0...1.1.1

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(May 17, 2022)

    Added

    • contains: Checks if the given key has a value or not
    • require: Checks to make sure the cache has the required keys, otherwise it will throw an error
    • valuesInCache: Returns a Dictionary containing only the key value pairs where the value is the same type as the generic type Value

    What's Changed

    • Develop by @0xLeif in https://github.com/0xOpenBytes/c/pull/5

    Full Changelog: https://github.com/0xOpenBytes/c/compare/1.0.1...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(May 6, 2022)

  • 1.0.0(May 6, 2022)

    c

    Micro Composition

    What is c?

    c is a simple composition framework. You have the ability to create transformations that are either unidirectional or bidirectional. There is also a cache that values can be set and resolved.

    Where can c be used?

    c can be used anywhere to create transformations or interact with the cache.

    Examples

    BiDirectionalTransformation of String and Int

    let transformer = c.transformer(
        from: { string in Int(string) },
        to: { int in "\(String(describing: int))" }
    )
    
    let string = transformer.to(3)
    let int = transformer.from("3")
    
    try t.assert(transformer.to(int), isEqualTo: string)
    

    Cache

    let cache = c.Cache()
    
    cache.set(value: Double.pi, forKey: "🥧")
    
    let pi: Double = cache.get("🥧") ?? 0
    
    try t.assert(pi, isEqualTo: .pi)
    
    let resolvedValue: Double = cache.resolve("🥧")
    
    try t.assert(resolvedValue, isEqualTo: .pi)
                        
    cache.remove("🥧")
    
    let nilValue: Double? = cache.get("🥧")
    
    try t.assert(isNil: nilValue)
    

    KeyedCache

    enum CacheKey: Hashable { ... }
    
    let cache = c.KeyedCache<CacheKey>()
    
    cache.set(value: Double.pi, forKey: CacheKey.piKey)
    
    let pi: Double = cache.get(.piKey) ?? 0
    
    try t.assert(pi, isEqualTo: .pi)
    
    let resolvedValue: Double = cache.resolve(.piKey)
    
    try t.assert(resolvedValue, isEqualTo: .pi)
                        
    cache.remove(.piKey)
    
    let nilValue: Double? = cache.get(.piKey)
    
    try t.assert(isNil: nilValue)
    

    JSON

    enum MockJSONKey: String, Hashable {
        case name, number, bool, invalid_key
    }
    
    struct MockJSON: Codable {
        var name: String
        var number: Int
        var bool: Bool
    }
    
    let jsonData: Data = try! JSONEncoder().encode(MockJSON(name: "Twitch", number: 5, bool: false))
    
    let json: c.JSON<MockJSONKey> = .init(data: jsonData)
    
    XCTAssertEqual(json.resolve(.name), "Twitch")
    XCTAssertEqual(json.resolve(.number), 5)
    XCTAssertEqual(json.resolve(.bool), false)
    
    let invalid_key: Bool? = json.get(.invalid_key)
    
    XCTAssertNil(json.get(.invalid_key))
    XCTAssertNil(invalid_key)
    
    json.set(value: "Leif", forKey: .name)
    
    XCTAssertEqual(json.resolve(.name), "Leif"
    

    Global Cache

    let someCache: Cache = ...
    
    // Set the value of a Cache with any hashable key
    c.set(value: someCache, forKey: "someCache")
    
    // Get an optional Cache using any hashable key
    let anotherCache: Cache? = c.get(0)
    
    // Require that a Cache exist using a `.get` with a force unwrap
    let requiredCache: Cache = c.resolve(0)
    
    let keyedCache: KeyedCache<String> = c.resolve(...)
    

    Full Changelog: https://github.com/0xOpenBytes/c/compare/0.4.0...1.0.0

    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(May 6, 2022)

    What's Changed

    • Feature/json by @0xLeif in https://github.com/0xOpenBytes/c/pull/4

    Full Changelog: https://github.com/0xOpenBytes/c/compare/0.3.0...0.4.0

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Apr 30, 2022)

    What's Changed

    • Feature/keyed cache by @0xLeif in https://github.com/0xOpenBytes/c/pull/3

    Full Changelog: https://github.com/0xOpenBytes/c/compare/0.2.0...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Mar 2, 2022)

    What's Changed

    • Cache Update by @0xLeif in https://github.com/0xOpenBytes/c/pull/2

    Full Changelog: https://github.com/0xOpenBytes/c/compare/0.1.0...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Feb 24, 2022)

    c

    Micro Composition

    What is c?

    c is a simple composition framework. You have the ability to create transformations that are either unidirectional or bidirectional. There is also a cache that values can be set and resolved.

    Where can c be used?

    c can be used anywhere to create transformations or interact with the cache.

    Examples

    BiDirectionalTransformation of String and Int

    let transformer = c.transformer(
        from: { string in Int(string) },
        to: { int in "\(String(describing: int))" }
    )
    
    let string = transformer.to(3)
    let int = transformer.from("3")
    
    try t.assert(transformer.to(int), isEqualTo: string)
    

    Cache

    c.set(value: Double.pi, forKey: "🥧")
    
    let pi: Double = c.get("🥧") ?? 0
    
    try t.assert(pi, isEqualTo: .pi)
    
    let resolvedValue: Double = c.resolve("🥧")
    
    try t.assert(resolvedValue, isEqualTo: .pi)
    
    Source code(tar.gz)
    Source code(zip)
Owner
OpenBytes
OpenBytes
🚀 Create, maintain, and interact with Xcode projects at scale

What's Tuist ?? Tuist is a command line tool that helps you generate, maintain and interact with Xcode projects. It's open source and written in Swift

Tuist 3.1k Jan 6, 2023
Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

Peter Larson 17 Jun 27, 2022
Create an app using VIPER architecture

How not to get confused with VIPER Implementation This is a demo app to share in swift study group using VIPER Architechture When using VIPER Architec

null 1 Dec 4, 2021
Create dynamic wallpapers for macOS

Equinox Create macOS native wallpapers Description Equinox is an application that allows you to create macOS native wallpapers. Starting macOS Mojave

Dmitry Meduho 683 Jan 5, 2023
Goal: Create an iOS app with two views, MainViewController and DetailViewController

Goal: Create an iOS app with two views, MainViewController and DetailViewController

Jesse Rae 0 Jan 23, 2022
TagKit makes it easy to create tag-based apps in SwiftUI.

About TagKit TagKit makes it easy to work with tags in Swift and SwiftUI. The result can look like this or completely different: Tags and tag views ca

Daniel Saidi 18 Dec 23, 2022
A simple framework to output to a file, url, the console, or even register notification using UserNotifications

o is a simple framework to output to a file, url, the console, or even register notification using UserNotifications. o can also get input from a file, url, or console.

OpenBytes 4 Mar 18, 2022
Start your next Open-Source Swift Framework 📦

SwiftKit enables you to easily generate a cross platform Swift Framework from your command line. It is the best way to start your next Open-Source Swi

Sven Tiigi 821 Dec 28, 2022
Easily generate cross platform Swift framework projects from the command line

SwiftPlate Easily generate cross platform Swift framework projects from the command line. SwiftPlate will generate Xcode projects for you in seconds,

John Sundell 1.8k Dec 27, 2022
A Swift wrapper around the CoreSymbolication private framework on macOS.

CoreSymbolication provides a very powerful system for looking up and extracting symbolic information from mach-o executables, dyld shared caches, and dSYMs.

Stacksift 7 Nov 21, 2022