Skip to content

Commit

Permalink
Support Swift 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
koher committed Apr 2, 2018
1 parent 3d6d5bf commit 3cb2984
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
12 changes: 10 additions & 2 deletions Sources/PromiseK/Throws.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ extension Promise {
}
}

private func _flatMap<T>(_ transform: @escaping (Value) -> Promise<T>) -> Promise<T> {
return flatMap(transform)
}

public func flatMap<T>(_ transform: @escaping (Value) -> Promise<() throws -> T>) -> Promise<() throws -> T> {
return _flatMap(transform)
}

public func flatMap<T>(_ transform: @escaping (Value) throws -> Promise<T>) -> Promise<() throws -> T> {
return flatMap { value in
return _flatMap { value in
do {
return try transform(value).map { value in { value } }
} catch let error {
Expand All @@ -21,7 +29,7 @@ extension Promise {
}

public func flatMap<T>(_ 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 {
Expand Down

0 comments on commit 3cb2984

Please sign in to comment.