GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use `JSValue` instead for `JSPromise`'s closure return types · wfltaylor/JavaScriptKit@5eed2c6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Sources/JavaScriptKit/BasicObjects
    • JSPromise.swift
  • Tests/JavaScriptEventLoopTests
    • JSPromiseTests.swift
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Sources/JavaScriptKit/BasicObjects/JSPromise.swift‎

Copy file name to clipboardExpand all lines: Sources/JavaScriptKit/BasicObjects/JSPromise.swift
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class JSPromise: JSBridgedClass {
8686

8787
/// Schedules the `success` closure to be invoked on successful completion of `self`.
8888
@discardableResult
89-
public func then(success: @escaping (JSValue) -> some ConvertibleToJSValue) -> JSPromise {
89+
public func then(success: @escaping (JSValue) -> JSValue) -> JSPromise {
9090
let closure = JSOneshotClosure {
9191
success($0[0]).jsValue
9292
}
@@ -98,7 +98,7 @@ public final class JSPromise: JSBridgedClass {
9898
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
9999
@discardableResult
100100
public func then(
101-
success: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
101+
success: sending @escaping (sending JSValue) async throws -> JSValue
102102
) -> JSPromise {
103103
let closure = JSOneshotClosure.async {
104104
try await success($0[0]).jsValue
@@ -110,8 +110,8 @@ public final class JSPromise: JSBridgedClass {
110110
/// Schedules the `success` closure to be invoked on successful completion of `self`.
111111
@discardableResult
112112
public func then(
113-
success: @escaping (sending JSValue) -> some ConvertibleToJSValue,
114-
failure: @escaping (sending JSValue) -> some ConvertibleToJSValue
113+
success: @escaping (sending JSValue) -> JSValue,
114+
failure: @escaping (sending JSValue) -> JSValue
115115
) -> JSPromise {
116116
let successClosure = JSOneshotClosure {
117117
success($0[0]).jsValue
@@ -127,8 +127,8 @@ public final class JSPromise: JSBridgedClass {
127127
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
128128
@discardableResult
129129
public func then(
130-
success: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue,
131-
failure: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
130+
success: sending @escaping (sending JSValue) async throws -> JSValue,
131+
failure: sending @escaping (sending JSValue) async throws -> JSValue
132132
) -> JSPromise {
133133
let successClosure = JSOneshotClosure.async {
134134
try await success($0[0]).jsValue
@@ -143,7 +143,7 @@ public final class JSPromise: JSBridgedClass {
143143
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
144144
@discardableResult
145145
public func `catch`(
146-
failure: @escaping (sending JSValue) -> some ConvertibleToJSValue
146+
failure: @escaping (sending JSValue) -> JSValue
147147
)
148148
-> JSPromise
149149
{
@@ -158,7 +158,7 @@ public final class JSPromise: JSBridgedClass {
158158
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
159159
@discardableResult
160160
public func `catch`(
161-
failure: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
161+
failure: sending @escaping (sending JSValue) async throws -> JSValue
162162
) -> JSPromise {
163163
let closure = JSOneshotClosure.async {
164164
try await failure($0[0]).jsValue
Collapse file

‎Tests/JavaScriptEventLoopTests/JSPromiseTests.swift‎

Copy file name to clipboardExpand all lines: Tests/JavaScriptEventLoopTests/JSPromiseTests.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ final class JSPromiseTests: XCTestCase {
99
p1 = p1.then { value in
1010
XCTAssertEqual(value, .null)
1111
continuation.resume()
12-
return JSValue.number(1.0)
12+
return JSValue.number(1.0).jsValue
1313
}
1414
}
1515
await withCheckedContinuation { continuation in
1616
p1 = p1.then { value in
1717
XCTAssertEqual(value, .number(1.0))
1818
continuation.resume()
19-
return JSPromise.resolve(JSValue.boolean(true))
19+
return JSPromise.resolve(JSValue.boolean(true)).jsValue
2020
}
2121
}
2222
await withCheckedContinuation { continuation in
@@ -48,7 +48,7 @@ final class JSPromiseTests: XCTestCase {
4848
p2 = p2.then { value in
4949
XCTAssertEqual(value, .boolean(true))
5050
continuation.resume()
51-
return JSPromise.reject(JSValue.number(2.0))
51+
return JSPromise.reject(JSValue.number(2.0)).jsValue
5252
}
5353
}
5454
await withCheckedContinuation { continuation in

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.