Skip to content

Commit 99ae28c

Browse files
authored
Merge pull request #164 from apple/prefix-await
Rename "await" to "tsc_await"
2 parents 8123987 + 3f703fc commit 99ae28c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Sources/TSCBasic/Await.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
/// should be passed to the async method's completion handler.
1515
/// - Returns: The value wrapped by the async method's result.
1616
/// - Throws: The error wrapped by the async method's result
17-
public func await<T, ErrorType>(_ body: (@escaping (Result<T, ErrorType>) -> Void) -> Void) throws -> T {
18-
return try await(body).get()
17+
public func tsc_await<T, ErrorType>(_ body: (@escaping (Result<T, ErrorType>) -> Void) -> Void) throws -> T {
18+
return try tsc_await(body).get()
1919
}
2020

21-
public func await<T>(_ body: (@escaping (T) -> Void) -> Void) -> T {
21+
public func tsc_await<T>(_ body: (@escaping (T) -> Void) -> Void) -> T {
2222
let condition = Condition()
2323
var result: T? = nil
2424
body { theResult in
@@ -34,3 +34,13 @@ public func await<T>(_ body: (@escaping (T) -> Void) -> Void) -> T {
3434
}
3535
return result!
3636
}
37+
38+
@available(*, deprecated, renamed: "tsc_await")
39+
public func await<T, ErrorType>(_ body: (@escaping (Result<T, ErrorType>) -> Void) -> Void) throws -> T {
40+
return try tsc_await(body).get()
41+
}
42+
43+
@available(*, deprecated, renamed: "tsc_await")
44+
public func await<T>(_ body: (@escaping (T) -> Void) -> Void) -> T {
45+
return tsc_await(body)
46+
}

Tests/TSCBasicTests/AwaitTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class AwaitTests: XCTestCase {
3232
}
3333

3434
func testBasics() throws {
35-
let value = try await { async("Hi", $0) }
35+
let value = try tsc_await { async("Hi", $0) }
3636
XCTAssertEqual("Hi", value)
3737

3838
do {
39-
let value = try await { throwingAsync("Hi", $0) }
39+
let value = try tsc_await { throwingAsync("Hi", $0) }
4040
XCTFail("Unexpected success \(value)")
4141
} catch {
4242
XCTAssertEqual(error as? DummyError, DummyError.error)

0 commit comments

Comments
 (0)