├── CHANGELOG.md ├── GeneralUtility ├── GeneralUtility.h └── Info.plist ├── LICENSE.txt ├── Package.swift ├── README.md ├── Sources └── GeneralUtility │ └── Utility.swift └── Tests └── Tests └── test.swift /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## 0.0.8 4 | Moved out all specific utility to its own Misc Utility library. This now only vends the core enum 5 | 6 | ## 0.0.7 7 | Update README.md to use modern dependency example 8 | 9 | ## 0.0.6 10 | Restructure: `Result` to have a default error when data and error are nil. 11 | Add: Async data 12 | Restructure: Sync data to use Async data task 13 | Add: Data tests 14 | 15 | ## 0.0.5 16 | 17 | Add: Exponentiation 18 | Add: Schoolbook Rounding 19 | 20 | ## 0.0.3 21 | 22 | Add: FileManager touch (url and string path) 23 | Add: URL versioning 24 | 25 | Added tests 26 | 27 | Refactored Mac-specific code out to Mac-General-Utility 28 | 29 | ## 0.0.2 30 | 31 | Add: isDir checks (FileManger, String), mutable partition slices 32 | 33 | ## 0.0.1 34 | 35 | Initial Commit 36 | 37 | -------------------------------------------------------------------------------- /GeneralUtility/GeneralUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // GeneralUtility.h 3 | // GeneralUtility 4 | // 5 | // Created by Erica Sadun on 7/14/20. 6 | // Copyright © 2020 Erica Sadun. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for GeneralUtility. 12 | FOUNDATION_EXPORT double GeneralUtilityVersionNumber; 13 | 14 | //! Project version string for GeneralUtility. 15 | FOUNDATION_EXPORT const unsigned char GeneralUtilityVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /GeneralUtility/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSHumanReadableCopyright 22 | Copyright © 2020 Erica Sadun. All rights reserved. 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Erica Sadun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "Swift-General-Utility", 8 | platforms: [ 9 | .macOS(.v10_12) 10 | ], 11 | products: [ 12 | .library( 13 | name: "GeneralUtility", 14 | targets: ["GeneralUtility"]), 15 | ], 16 | dependencies: [], 17 | targets: [ 18 | .target( 19 | name: "GeneralUtility", 20 | dependencies: [], 21 | path: "Sources/" 22 | ), 23 | .testTarget( 24 | name: "Tests", 25 | dependencies: ["GeneralUtility"]) 26 | ], 27 | swiftLanguageVersions: [ 28 | .v5 29 | ] 30 | ) 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift General Utility 2 | 3 | Support code for developing Swift code. 4 | 5 | ## Contents 6 | 7 | ### Utility 8 | 9 | A `Utility` namespace for hosting utility functionality withing your app. 10 | 11 | ### Applicative 12 | 13 | Inline functional `Applicative` protocol that supports applying a closure to an instance, returning the instance. 14 | 15 | *Note:* Types must conform to the protocol to inherit the behavior, as non-nominal types like `Any` cannot be extended. 16 | 17 | ### RuntimeError 18 | 19 | A stringity error type representing runtime errors. 20 | 21 | ### Side effect utility 22 | 23 | Enables debugging within method chains and condition cascades. 24 | 25 | ### SynchronousData 26 | 27 | Request synchronous data using `URLSession`. 28 | 29 | ### Type Utilities 30 | 31 | #### Collection utility 32 | 33 | * Partition split. 34 | 35 | #### Result utility 36 | 37 | * Initializes a `Result` from a completion handler's `(data?, error?)`. 38 | 39 | #### String utility 40 | 41 | * Trim a string 42 | 43 | 44 | ## Installation 45 | 46 | PROJECT > Swift Packages > Install: 47 | 48 | ``` 49 | https://github.com/erica/https://github.com/erica/Swift-General-Utility 50 | ``` 51 | 52 | SwiftPM: 53 | 54 | ``` 55 | dependencies: [ 56 | .package(url: "https://github.com/erica/Swift-General-Utility", from: "x.x.x"), // replace with version 57 | ], 58 | targets: [ 59 | .target( 60 | name: "TARGET-NAME", 61 | dependencies: [ 62 | .product(name: "GeneralUtility", package: "Swift-General-Utility"), 63 | ], 64 | ), 65 | ], 66 | ``` 67 | -------------------------------------------------------------------------------- /Sources/GeneralUtility/Utility.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2020 Erica Sadun. All rights reserved. 2 | 3 | import Foundation 4 | 5 | /// A `Utility` namespace for hosting utility functionality 6 | public enum Utility {} 7 | -------------------------------------------------------------------------------- /Tests/Tests/test.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import GeneralUtility 3 | 4 | class EmptyTests: XCTestCase { 5 | override func setUpWithError() throws { 6 | } 7 | 8 | override func tearDownWithError() throws { 9 | } 10 | 11 | func trivialTest() throws { 12 | XCTAssertTrue(true) 13 | } 14 | } 15 | --------------------------------------------------------------------------------