Skip to content

Commit

Permalink
Reset Files
Browse files Browse the repository at this point in the history
  • Loading branch information
ObuchiYuki committed Feb 2, 2022
1 parent 0122b86 commit 71a434a
Show file tree
Hide file tree
Showing 237 changed files with 10,721 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Mac
.DS_Store

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
633 changes: 633 additions & 0 deletions CoreUtil/CoreUtil.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
17 changes: 17 additions & 0 deletions CoreUtil/CoreUtil/Class/Action.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Action.swift
// CoreUtil
//
// Created by yuki on 2022/01/16.
// Copyright © 2022 yuki. All rights reserved.
//

public struct Action {
public let title: String
public let action: () -> ()

public init(title: String, action: @escaping () -> ()) {
self.title = title
self.action = action
}
}
92 changes: 92 additions & 0 deletions CoreUtil/CoreUtil/Class/Delta.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// Delta.swift
// CoreUtil
//
// Created by yuki on 2020/05/14.
// Copyright © 2020 yuki. All rights reserved.
//

public enum Delta<Value> {
case to(Value)
case by(Value)
}

extension Delta {
@inlinable public func map<T>(_ tranceform: (Value) throws -> T) rethrows -> Delta<T> {
switch self {
case .to(let value): return .to(try tranceform(value))
case .by(let value): return .by(try tranceform(value))
}
}

@inlinable public func reduce(_ initialValue: Value, _ tranceform: (Value, Value) throws -> Value) rethrows -> Value {
switch self {
case .to(let value): return value
case .by(let value): return try tranceform(initialValue, value)
}
}

@inlinable public func takeValue() -> Value {
switch self {
case .to(let value): return value
case .by(let value): return value
}
}

@inlinable public func apply(_ initialValue: inout Value, _ tranceform: (Value, Value) throws -> Value) rethrows {
initialValue = try reduce(initialValue, tranceform)
}
}

extension Delta where Value: AdditiveArithmetic {
@inlinable public func reduce(_ initialValue: Value) -> Value {
reduce(initialValue, +)
}
@inlinable public func apply(_ initialValue: inout Value) {
apply(&initialValue, +)
}

@inlinable public static func += (_ initialValue: inout Value, delta: Delta<Value>) {
delta.apply(&initialValue)
}
}

extension Delta where Value: RangeReplaceableCollection {
@inlinable public func reduce(_ initialValue: Value) -> Value {
reduce(initialValue, +)
}
@inlinable public func apply(_ initialValue: inout Value) {
apply(&initialValue, +)
}

@inlinable public static func += (_ initialValue: inout Value, delta: Delta<Value>) {
delta.apply(&initialValue)
}
}

extension Delta: Encodable where Value: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .by(let value): try container.encode(["by": value])
case .to(let value): try container.encode(["to": value])
}
}
}

extension Delta: Decodable where Value: Decodable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let content = try container.decode([String: Value].self)

guard let (key, value) = content.first else {
throw DecodingError.dataCorruptedError(in: container, debugDescription: "Empty container")
}

switch key {
case "by": self = .by(value)
case "to": self = .to(value)
default: throw DecodingError.dataCorruptedError(in: container, debugDescription: "Unkown key '\(key)'")
}
}
}
Loading

0 comments on commit 71a434a

Please sign in to comment.