Skip to content

Commit bb5e08b

Browse files
committed
fix: Move NOTE comment to the fetch function it describes
1 parent fd51424 commit bb5e08b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/promise_subclass/mod.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
* A Promise subclass with an extra method, similar to Anthropic SDK's APIPromise.
88
* The instrumented wrapper must preserve the original return type so callers
99
* can still access subclass-specific methods like `.withResponse()`.
10-
*
11-
* NOTE: This function is intentionally NOT async. Async functions always wrap
12-
* their return value in a native Promise, losing the subclass type. The real-
13-
* world scenario (e.g. Anthropic SDK's APIPromise) uses a non-async function
14-
* that explicitly constructs and returns a Promise subclass instance.
1510
*/
1611
class ExtendedPromise extends Promise {
1712
withResponse () {
1813
return this.then(result => ({ data: result, response: { status: 200 } }))
1914
}
2015
}
2116

17+
/**
18+
* NOTE: Intentionally NOT async. Async functions always wrap their return value
19+
* in a native Promise, losing the subclass type. The real-world scenario
20+
* (e.g. Anthropic SDK's APIPromise) uses a non-async function that explicitly
21+
* constructs and returns a Promise subclass instance.
22+
*/
2223
function fetch (url) {
2324
return new ExtendedPromise(resolve => resolve(42))
2425
}

0 commit comments

Comments
 (0)