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 {
3131final class FunctionsSerializer {
3232 // MARK: - Internal APIs
3333
34- func encode( _ object: Any ) throws -> AnyObject {
34+ func encode( _ object: Any ) throws -> Any {
3535 if object is NSNull {
36- return object as AnyObject
36+ return object
3737 } else if object is NSNumber {
3838 return try encodeNumber ( object as! NSNumber )
3939 } 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 {
4342 let encoded = NSMutableDictionary ( )
4443 try dict. forEach { key, value in
4544 encoded [ key] = try encode ( value)
4645 }
4746 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)
5350 }
54- return encoded
55-
5651 } else {
5752 throw Error . unsupportedType ( typeName: typeName ( of: object) )
5853 }
You can’t perform that action at this time.
0 commit comments