Skip to content

Commit

Permalink
fix: update bundle decode helper to take extension
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed May 12, 2021
1 parent ab20a39 commit 5e4c6c9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/ExtensionKit/Foundation/Bundle.swift
Expand Up @@ -26,13 +26,15 @@ public extension Bundle {
/// - keyDecodingStrategy: key decoding strategy
/// - Returns: Future
func decode<T: Decodable>(
_ type: T.Type, from file: String,
_ type: T.Type,
fromFile file: String,
withExtension `extension`: String? = nil,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys
) -> Deferred<Future<T, Error>> {
Deferred {
Future { promise in
guard let url = self.url(forResource: file, withExtension: nil) else {
guard let url = self.url(forResource: file, withExtension: `extension`) else {
promise(.failure(DataDecodingError.urlNotFound("Failed to locate \(file) in bundle.")))
return
}
Expand Down

0 comments on commit 5e4c6c9

Please sign in to comment.