Giter Site home page Giter Site logo

core's Introduction

Core

Protocols

AutoCodable aka AutoEncodable and AutoDecodable

A protocol for initializing and storing known data types

An object that conforms to AutoCodable or the in practice protocol JSONCodable

struct Value: AutoCodable {
 static let encoder = JSONEncoder()
 static let decoder = JSONDecoder()
}
// or conform to an autocodable protocol if the value is codable
extension Value: JSONCodable {}

// auto encode and decode JSON formatted values
let value = Value()
let data = value.data
let decoded = try Value(data)

Infallible

This is a protocol that allows values to be unwrapped through inference by declaring the static property defaultValue

Expressible Protocols

ExpressibleAsEmpty

Allows the static property empty, local property isEmpty/notEmpty to be declared and wrapped into an optional that is nil when empty

ExpressibleAsZero

Allows a value to be expressed using the static property zero

ExpressibleAsStart

Allows a value to be expressed using the static property start

Structures

RecursiveNode

A recursive structure that stores the current position of a node, relative to a starting node. This value doesn’t store elements (or itself), it points to a set of arrays [[Self]] and [[Value]] so they can be stored recursively and separately from the higher level, which is great for reflection and creating recursive values that would have problems in arrays or structs and may need to indicate some form of hiearchical or graph like structure. As more testing is done, there will be more examples and documentation.

Extensions

Extended functionality for common types such as Duration, String, and Optional, core types such as, Infallible and Randomizable, and a couple of convenience functions.

A way to unwrap many values or simplify testing

try some.throwing()
try optional.throwing(Error.notFound)

A randomized Date within a certain range

let date = Date.random // minute to 27 days past
let random = Date.random(60 ..< 86400) // minute to a day

Delayed async task and sleep using the public namespace

try await withTask(after: 1e9) { ... } 
try await sleep(for: .seconds(1))

Components

Common names and expressions

Expressions

Regex

The default namespace for common regular expressions that can be accessed from a String and used as parameters

let keyPath: KeyPath<Regex, String> = \.url
let expression = String.regex[keyPath: keyPath] // the expanded pattern

Context

Subject

A string that represents any group of objects such as error or info

extension Subject {
 static let debug: Self = "debug"
}
let subject = Subject.debug

Descriptor

A string, such as optional or nil that describes a subject or object

extension Descriptor {
 static let final: Self = "final"
}
let descriptor = Descriptor.final

core's People

Contributors

entangleduser avatar acrlc avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

entangleduser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.