Skip to content

Commit 1b1c179

Browse files
committed
swiftformat
1 parent 1fae293 commit 1b1c179

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Sources/ExtrasJSON/JSONValue.swift

+18-18
Original file line numberDiff line numberDiff line change
@@ -144,52 +144,52 @@ extension JSONValue {
144144
}
145145

146146
/// Value Getters
147-
extension JSONValue {
147+
public extension JSONValue {
148148
/// If this `JSONValue` is a `.number` that can be losslessly represented as a `Double`, return it as a `Double`.
149149
/// Otherwise, return nil.
150-
public var doubleValue: Double? {
151-
guard case let .number(n) = self else {
150+
var doubleValue: Double? {
151+
guard case .number(let n) = self else {
152152
return nil
153153
}
154154
return Double(n)
155155
}
156156

157157
/// If this `JSONValue` is a `.number` that can be losslessly represented as an `Int`, return it as a `Int`.
158158
/// Otherwise, return nil.
159-
public var intValue: Int? {
160-
guard case let.number(n) = self else {
159+
var intValue: Int? {
160+
guard case .number(let n) = self else {
161161
return nil
162162
}
163163
return Int(n)
164164
}
165165

166166
/// If this `JSONValue` is a `.string`, return it as a `String`. Otherwise, return nil.
167-
public var stringValue: String? {
168-
guard case let .string(s) = self else {
167+
var stringValue: String? {
168+
guard case .string(let s) = self else {
169169
return nil
170170
}
171171
return s
172172
}
173173

174174
/// If this `JSONValue` is a `.bool`, return it as a `Bool`. Otherwise, return nil.
175-
public var boolValue: Bool? {
176-
guard case let .bool(b) = self else {
175+
var boolValue: Bool? {
176+
guard case .bool(let b) = self else {
177177
return nil
178178
}
179179
return b
180180
}
181181

182182
/// If this `JSONValue` is a `.array`, return it as a `[JSONValue]`. Otherwise, return nil.
183-
public var arrayValue: [JSONValue]? {
184-
guard case let .array(a) = self else {
183+
var arrayValue: [JSONValue]? {
184+
guard case .array(let a) = self else {
185185
return nil
186186
}
187187
return a
188188
}
189189

190190
/// If this `JSONValue` is a `.object`, return it as a `[String: JSONValue]`. Otherwise, return nil.
191-
public var objectValue: [String: JSONValue]? {
192-
guard case let .object(o) = self else {
191+
var objectValue: [String: JSONValue]? {
192+
guard case .object(let o) = self else {
193193
return nil
194194
}
195195
return o
@@ -311,7 +311,7 @@ extension JSONValue: Codable {
311311
public func encode(to encoder: Encoder) throws {
312312
var container = encoder.singleValueContainer()
313313
switch self {
314-
case let .number(n):
314+
case .number(let n):
315315
if let int = self.intValue {
316316
try container.encode(int)
317317
} else if let double = self.doubleValue {
@@ -325,13 +325,13 @@ extension JSONValue: Codable {
325325
)
326326
)
327327
}
328-
case let .string(s):
328+
case .string(let s):
329329
try container.encode(s)
330-
case let .bool(b):
330+
case .bool(let b):
331331
try container.encode(b)
332-
case let .array(a):
332+
case .array(let a):
333333
try container.encode(a)
334-
case let .object(o):
334+
case .object(let o):
335335
try container.encode(o)
336336
case .null:
337337
try container.encodeNil()

Tests/ExtrasJSONTests/JSONValueExtensionsTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import XCTest
21
import ExtrasJSON
2+
import XCTest
33

44
class JSONValueDecodingTests: XCTestCase {
55
let encoder = XJSONEncoder()

0 commit comments

Comments
 (0)