From 3cb2984d4d793a0db7e906ffa41f420afb520b66 Mon Sep 17 00:00:00 2001 From: Yuta Koshizawa Date: Tue, 3 Apr 2018 02:27:09 +0900 Subject: [PATCH] Support Swift 4.1 --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ Sources/PromiseK/Throws.swift | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 PromiseK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/PromiseK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PromiseK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PromiseK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Sources/PromiseK/Throws.swift b/Sources/PromiseK/Throws.swift index f8ed715..6d8de7c 100644 --- a/Sources/PromiseK/Throws.swift +++ b/Sources/PromiseK/Throws.swift @@ -10,8 +10,16 @@ extension Promise { } } + private func _flatMap(_ transform: @escaping (Value) -> Promise) -> Promise { + return flatMap(transform) + } + + public func flatMap(_ transform: @escaping (Value) -> Promise<() throws -> T>) -> Promise<() throws -> T> { + return _flatMap(transform) + } + public func flatMap(_ transform: @escaping (Value) throws -> Promise) -> Promise<() throws -> T> { - return flatMap { value in + return _flatMap { value in do { return try transform(value).map { value in { value } } } catch let error { @@ -21,7 +29,7 @@ extension Promise { } public func flatMap(_ transform: @escaping (Value) throws -> Promise<() throws -> T>) -> Promise<() throws -> T> { - return flatMap { value in + return _flatMap { value in do { return try transform(value) } catch let error {