File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
FirebaseFunctions/Sources/Internal Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -31,28 +31,23 @@ extension FunctionsSerializer {
31
31
final class FunctionsSerializer {
32
32
// MARK: - Internal APIs
33
33
34
- func encode( _ object: Any ) throws -> AnyObject {
34
+ func encode( _ object: Any ) throws -> Any {
35
35
if object is NSNull {
36
- return object as AnyObject
36
+ return object
37
37
} else if object is NSNumber {
38
38
return try encodeNumber ( object as! NSNumber )
39
39
} else if object is NSString {
40
- return object as AnyObject
41
- } else if object is NSDictionary {
42
- let dict = object as! NSDictionary
40
+ return object
41
+ } else if let dict = object as? NSDictionary {
43
42
let encoded = NSMutableDictionary ( )
44
43
try dict. forEach { key, value in
45
44
encoded [ key] = try encode ( value)
46
45
}
47
46
return encoded
48
- } else if object is NSArray {
49
- let array = object as! NSArray
50
- let encoded = NSMutableArray ( )
51
- try array. forEach { element in
52
- try encoded. add ( encode ( element) )
47
+ } else if let array = object as? NSArray {
48
+ return try array. map { element in
49
+ try encode ( element)
53
50
}
54
- return encoded
55
-
56
51
} else {
57
52
throw Error . unsupportedType ( typeName: typeName ( of: object) )
58
53
}
You can’t perform that action at this time.
0 commit comments