Skip to content

Commit ccbf2fd

Browse files
committed
update library
Signed-off-by: Nguyen Phong <nguyenphong.mobile.engineer@gmail.com> Signed-off-by: Mike Packard <nguyenphong.mobile.engineer@gmail.com> Signed-off-by: NguyenPhongVN <nguyenphong.mobile.engineer@gmail.com>
1 parent c861a7f commit ccbf2fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+150
-114
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>Builder.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>1</integer>
11+
</dict>
12+
<key>DataStructures.xcscheme_^#shared#^_</key>
13+
<dict>
14+
<key>orderHint</key>
15+
<integer>2</integer>
16+
</dict>
17+
<key>Transform.xcscheme_^#shared#^_</key>
18+
<dict>
19+
<key>orderHint</key>
20+
<integer>3</integer>
21+
</dict>
22+
<key>swift-extension-Package.xcscheme_^#shared#^_</key>
23+
<dict>
24+
<key>orderHint</key>
25+
<integer>0</integer>
26+
</dict>
27+
</dict>
28+
</dict>
29+
</plist>
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@
99
<key>orderHint</key>
1010
<integer>1</integer>
1111
</dict>
12-
<key>ConvertSwift-Package.xcscheme_^#shared#^_</key>
13-
<dict>
14-
<key>orderHint</key>
15-
<integer>3</integer>
16-
</dict>
17-
<key>ConvertSwift.xcscheme_^#shared#^_</key>
12+
<key>DataStructures.xcscheme_^#shared#^_</key>
1813
<dict>
1914
<key>orderHint</key>
2015
<integer>2</integer>
2116
</dict>
22-
<key>DataStructures.xcscheme_^#shared#^_</key>
17+
<key>Transform.xcscheme_^#shared#^_</key>
2318
<dict>
2419
<key>orderHint</key>
2520
<integer>3</integer>
2621
</dict>
27-
<key>SwiftExtension-Package.xcscheme_^#shared#^_</key>
22+
<key>swift-extension-Package.xcscheme_^#shared#^_</key>
2823
<dict>
2924
<key>orderHint</key>
3025
<integer>0</integer>
@@ -37,17 +32,17 @@
3732
<key>primary</key>
3833
<true/>
3934
</dict>
40-
<key>ConvertSwift</key>
35+
<key>DataStructures</key>
4136
<dict>
4237
<key>primary</key>
4338
<true/>
4439
</dict>
45-
<key>ConvertSwiftTests</key>
40+
<key>Transform</key>
4641
<dict>
4742
<key>primary</key>
4843
<true/>
4944
</dict>
50-
<key>DataStructures</key>
45+
<key>UnitTests</key>
5146
<dict>
5247
<key>primary</key>
5348
<true/>

Package.resolved

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// swift-tools-version:5.5
1+
// swift-tools-version:5.8
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
7-
name: "SwiftExtension",
7+
name: "swift-extension",
88
products: [
99
// Products define the executables and libraries a package produces, and make them visible to other packages.
1010
.library(
11-
name: "ConvertSwift",
12-
targets: ["ConvertSwift"]),
11+
name: "Transform",
12+
targets: ["Transform"]),
1313
.library(
1414
name: "DataStructures",
1515
targets: ["DataStructures"]),
@@ -21,12 +21,13 @@ let package = Package(
2121
// Dependencies declare other packages that this package depends on.
2222
.package(url: "https://github.com/Quick/Quick.git", from: "4.0.0"),
2323
.package(url: "https://github.com/Quick/Nimble.git", from: "9.2.0"),
24+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0"),
2425
],
2526
targets: [
2627
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
2728
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2829
.target(
29-
name: "ConvertSwift",
30+
name: "Transform",
3031
dependencies: []),
3132
.target(
3233
name: "DataStructures",
@@ -35,7 +36,7 @@ let package = Package(
3536
name: "Builder",
3637
dependencies: []),
3738
.testTarget(
38-
name: "ConvertSwiftTests",
39-
dependencies: ["DataStructures", "ConvertSwift", "Quick", "Nimble"]),
39+
name: "UnitTests",
40+
dependencies: ["DataStructures", "Transform", "Quick", "Nimble"]),
4041
]
4142
)

Sources/Builder/ArrayBuilder.swift

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@ import Foundation
22

33
@resultBuilder
44
public enum ArrayBuilder<Element> {
5-
public static func buildBlock(_ components: Element...) -> [Element] {
5+
public typealias Component = [Element]
6+
7+
public static func buildBlock() -> Component {
8+
[]
9+
}
10+
11+
public static func buildBlock(_ component: Element) -> Component {
12+
[component]
13+
}
14+
15+
public static func buildBlock(_ components: Element...) -> Component {
616
components
717
}
18+
19+
public static func buildOptional(_ component: Element?) -> Component {
20+
if let component {
21+
return [component]
22+
} else {
23+
return []
24+
}
25+
}
26+
27+
public static func buildEither(first component: Element) -> Component {
28+
[component]
29+
}
30+
31+
public static func buildEither(second component: Element) -> Component {
32+
[component]
33+
}
34+
35+
public static func buildLimitedAvailability(_ component: Element) -> Component {
36+
[component]
37+
}
838
}
939

1040
public extension Array {

Sources/Builder/DictionaryBuilder.swift

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,39 @@ import Foundation
22

33
@resultBuilder
44
public enum DictionaryBuilder<Key: Hashable, Value> {
5-
static func buildBlock(_ components: Dictionary<Key, Value>...) -> Dictionary<Key, Value> {
6-
components.reduce(into: [:]) {
7-
$0.merge($1) { _, new in new }
5+
6+
public typealias Component = Dictionary<Key, Value>
7+
8+
public static func buildBlock() -> Component {
9+
[:]
10+
}
11+
12+
public static func buildBlock(_ component: Component) -> Component {
13+
component
14+
}
15+
16+
public static func buildBlock(_ components: Component...) -> Component {
17+
components.reduce(into: [:]) { result, next in
18+
result.merge(next) { $1 }
819
}
920
}
21+
22+
public static func buildOptional(_ component: Component?) -> Component {
23+
component ?? [:]
24+
}
25+
26+
public static func buildEither(first component: Component) -> Component {
27+
component
28+
}
29+
30+
public static func buildEither(second component: Component) -> Component {
31+
component
32+
}
33+
34+
public static func buildLimitedAvailability(_ component: Component) -> Component {
35+
component
36+
}
1037
}
11-
1238
public extension Dictionary {
1339
init(@DictionaryBuilder<Key, Value> builder: () -> Dictionary) {
1440
self = builder()

Sources/Builder/StringBuilder.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import Foundation
22

3-
public protocol StringBuilerProtocol {
4-
var value: String {get}
5-
}
6-
73
@resultBuilder
84
public enum StringBuilder {
9-
public static func buildArray(_ strings: [[String]]) -> [String] {
10-
strings.flatMap { $0 }
5+
public static func buildArray(_ strings: [String]) -> [String] {
6+
strings
117
}
128

139
public static func buildBlock(_ strings: [String]...) -> [String] {
14-
strings.flatMap { $0 }
10+
strings.flatMap{$0}
1511
}
1612

1713
public static func buildEither(first strings: [String]) -> [String] {

0 commit comments

Comments
 (0)