Skip to content

Commit

Permalink
Trim whitespace-only lines
Browse files Browse the repository at this point in the history
  • Loading branch information
delba committed Aug 18, 2019
1 parent d07470a commit 57804e1
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 120 deletions.
8 changes: 4 additions & 4 deletions Extensions/JASON+Alamofire.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ extension DataRequest {
- returns: A JASON.JSON object response serializer.
*/
static public func JASONReponseSerializer() -> DataResponseSerializer<JASON.JSON> {
return DataResponseSerializer { _, _, data, error in
return DataResponseSerializer { _, _, data, error in
guard error == nil else { return .failure(error!) }

return .success(JASON.JSON(data))
}
}

/**
Adds a handler to be called once the request has finished.

Expand All @@ -50,5 +50,5 @@ extension DataRequest {
public func responseJASON(completionHandler: @escaping (DataResponse<JASON.JSON>) -> Void) -> Self {
return response(responseSerializer: DataRequest.JASONReponseSerializer(), completionHandler: completionHandler)
}

}
34 changes: 17 additions & 17 deletions Extensions/JASON+JSONKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension JSON {
public subscript(key: JSONKey<Int8?>) -> Int8? {
return self[key.type].int8
}

/**
Returns the value associated with the given key as a 8-bit signed integer or 0 if not present/convertible.

Expand All @@ -48,7 +48,7 @@ extension JSON {
public subscript(key: JSONKey<Int8>) -> Int8 {
return self[key.type].int8Value
}

/**
Returns the value associated with the given key as a 16-bit signed integer or nil if not present/convertible.

Expand All @@ -59,7 +59,7 @@ extension JSON {
public subscript(key: JSONKey<Int16?>) -> Int16? {
return self[key.type].int16
}

/**
Returns the value associated with the given key as a 16-bit signed integer or 0 if not present/convertible.

Expand All @@ -70,7 +70,7 @@ extension JSON {
public subscript(key: JSONKey<Int16>) -> Int16 {
return self[key.type].int16Value
}

/**
Returns the value associated with the given key as a 32-bit signed integer or nil if not present/convertible.

Expand All @@ -81,7 +81,7 @@ extension JSON {
public subscript(key: JSONKey<Int32?>) -> Int32? {
return self[key.type].int32
}

/**
Returns the value associated with the given key as a 32-bit signed integer or 0 if not present/convertible.

Expand All @@ -92,7 +92,7 @@ extension JSON {
public subscript(key: JSONKey<Int32>) -> Int32 {
return self[key.type].int32Value
}

/**
Returns the value associated with the given key as a 64-bit signed integer or nil if not present/convertible.

Expand All @@ -103,7 +103,7 @@ extension JSON {
public subscript(key: JSONKey<Int64?>) -> Int64? {
return self[key.type].int64
}

/**
Returns the value associated with the given key as a 64-bit signed integer or 0 if not present/convertible.

Expand All @@ -129,7 +129,7 @@ extension JSON {
public subscript(key: JSONKey<UInt?>) -> UInt? {
return self[key.type].uInt
}

/**
Returns the value associated with the given key as a 64-bit unsigned integer or 0 if not present/convertible.

Expand All @@ -140,7 +140,7 @@ extension JSON {
public subscript(key: JSONKey<UInt>) -> UInt {
return self[key.type].uIntValue
}

/**
Returns the value associated with the given key as a 8-bit unsigned integer or nil if not present/convertible.

Expand All @@ -151,7 +151,7 @@ extension JSON {
public subscript(key: JSONKey<UInt8?>) -> UInt8? {
return self[key.type].uInt8
}

/**
Returns the value associated with the given key as a 8-bit unsigned integer or 0 if not present/convertible.

Expand All @@ -162,7 +162,7 @@ extension JSON {
public subscript(key: JSONKey<UInt8>) -> UInt8 {
return self[key.type].uInt8Value
}

/**
Returns the value associated with the given key as a 16-bit unsigned integer or nil if not present/convertible.

Expand All @@ -173,7 +173,7 @@ extension JSON {
public subscript(key: JSONKey<UInt16?>) -> UInt16? {
return self[key.type].uInt16
}

/**
Returns the value associated with the given key as a 16-bit unsigned integer or 0 if not present/convertible.

Expand All @@ -184,7 +184,7 @@ extension JSON {
public subscript(key: JSONKey<UInt16>) -> UInt16 {
return self[key.type].uInt16Value
}

/**
Returns the value associated with the given key as a 32-bit unsigned integer or nil if not present/convertible.

Expand All @@ -195,7 +195,7 @@ extension JSON {
public subscript(key: JSONKey<UInt32?>) -> UInt32? {
return self[key.type].uInt32
}

/**
Returns the value associated with the given key as a 32-bit unsigned integer or 0 if not present/convertible.

Expand All @@ -206,7 +206,7 @@ extension JSON {
public subscript(key: JSONKey<UInt32>) -> UInt32 {
return self[key.type].uInt32Value
}

/**
Returns the value associated with the given key as a 64-bit unsigned integer or nil if not present/convertible.

Expand All @@ -217,7 +217,7 @@ extension JSON {
public subscript(key: JSONKey<UInt64?>) -> UInt64? {
return self[key.type].uInt64
}

/**
Returns the value associated with the given key as a 64-bit unsigned integer or 0 if not present/convertible.

Expand All @@ -228,4 +228,4 @@ extension JSON {
public subscript(key: JSONKey<UInt64>) -> UInt64 {
return self[key.type].uInt64Value
}
}
}
1 change: 0 additions & 1 deletion Extensions/JASON+Operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ precedencegroup JASONPrecedence {

infix operator <| : JASONPrecedence


/// Assigns the value if it is present and convertible to T
public func <| <T: Any>( lhs: inout T, json: JSON) {
if let value = json.object as? T {
Expand Down
14 changes: 7 additions & 7 deletions Extensions/JASON+Properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ extension JSON {
public var int8: Int8? { return int != nil && intValue >= Int(Int8.min) && intValue <= Int(Int8.max) ? Int8(intValue) : nil }
// The value as a 8-bit signed integer or 0 if not present/convertible
public var int8Value: Int8 { return int8 ?? 0 }

// The value as a 16-bit signed integer or nil if not present/convertible
public var int16: Int16? { return int != nil && intValue >= Int(Int16.min) && intValue <= Int(Int16.max) ? Int16(intValue) : nil }
// The value as a 16-bit signed integer or 0 if not present/convertible
public var int16Value: Int16 { return int16 ?? 0 }

// The value as a 32-bit signed integer or nil if not present/convertible
public var int32: Int32? { return int != nil && intValue >= Int(Int32.min) && intValue <= Int(Int32.max) ? Int32(intValue) : nil }
// The value as a 64-bit signed integer or 0 if not present/convertible
public var int32Value: Int32 { return int32 ?? 0 }

// The value as a 64-bit signed integer or nil if not present/convertible
public var int64: Int64? { return int != nil ? Int64(intValue) : nil }
// The value as a 64-bit signed integer or 0 if not present/convertible
Expand All @@ -55,22 +55,22 @@ extension JSON {
public var uInt: UInt? { return int != nil && intValue >= 0 ? UInt(intValue) : nil }
// The value as a 64-bit unsigned integer or 0 if not present/convertible
public var uIntValue: UInt { return uInt ?? 0 }

// The value as a 8-bit signed integer or nil if not present/convertible
public var uInt8: UInt8? { return int != nil && intValue >= 0 && intValue <= Int(UInt8.max) ? UInt8(intValue) : nil }
// The value as a 8-bit signed integer or 0 if not present/convertible
public var uInt8Value: UInt8 { return uInt8 ?? 0 }

// The value as a 16-bit signed integer or nil if not present/convertible
public var uInt16: UInt16? { return int != nil && intValue >= 0 && intValue <= Int(UInt16.max) ? UInt16(intValue) : nil }
// The value as a 16-bit signed integer or 0 if not present/convertible
public var uInt16Value: UInt16 { return uInt16 ?? 0 }

// The value as a 32-bit signed integer or nil if not present/convertible
public var uInt32: UInt32? { return int != nil && intValue >= 0 && Int64(intValue) <= Int64(UInt32.max) ? UInt32(intValue) : nil }
// The value as a 32-bit signed integer or 0 if not present/convertible
public var uInt32Value: UInt32 { return uInt32 ?? 0 }

// The value as a 64-bit signed integer or nil if not present/convertible
public var uInt64: UInt64? { return int != nil && intValue >= 0 ? UInt64(intValue) : nil }
// The value as a 64-bit signed integer or 0 if not present/convertible
Expand Down
23 changes: 10 additions & 13 deletions Source/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public struct JSON {
/// The date formatter used for date conversions
public static var dateFormatter = DateFormatter()

/// The object on which any subsequent method operates
public let object: AnyObject?

Expand All @@ -52,7 +52,7 @@ public struct JSON {
public init(_ data: Data?) {
self.init(object: JSON.objectWithData(data))
}

/**
Creates an instance of JSON from a string.

Expand Down Expand Up @@ -113,7 +113,7 @@ extension JSON {

return JSON(object: nil)
}

/**
Creates a new instance of JSON.

Expand All @@ -124,29 +124,27 @@ extension JSON {
public subscript(path indexes: Any...) -> JSON {
return self[indexes]
}

internal subscript(indexes: [Any]) -> JSON {
if object == nil { return self }

var json = self

for index in indexes {
if let string = index as? String, let object = json.nsDictionary?[string] {
json = JSON(object)
continue
}

if let int = index as? Int, let object = json.nsArray?[safe: int] {
json = JSON(object)
continue
}

else {
} else {
json = JSON(object: nil)
break
}
}

return json
}
}
Expand All @@ -163,8 +161,7 @@ private extension JSON {
*/
static func objectWithData(_ data: Data?) -> Any? {
guard let data = data else { return nil }

return try? JSONSerialization.jsonObject(with: data)
}
}

Loading

0 comments on commit 57804e1

Please sign in to comment.