Skip to content

Commit

Permalink
Merge pull request #5 from koher/dev-3.1
Browse files Browse the repository at this point in the history
Support Swift 4.1
  • Loading branch information
koher authored Apr 2, 2018
2 parents 3d6d5bf + 3cb2984 commit 72bea2c
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 72bea2c

Please sign in to comment.