-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the test helper class
Deferred
with polyfilled `Promise.wit…
…hResolvers`.
- Loading branch information
1 parent
1bc03b9
commit 1135035
Showing
4 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-check | ||
|
||
// TODO: Delete this polyfill once all supported Node.js versions implement | ||
// `Promise.withResolvers`. | ||
Promise.withResolvers ??= () => new PromiseWithResolversReturn(); | ||
|
||
/** | ||
* A promise with resolvers. | ||
* @template T | ||
* @implements {PromiseWithResolvers<T>} | ||
*/ | ||
class PromiseWithResolversReturn { | ||
constructor() { | ||
/** @type {Promise<T>} */ | ||
this.promise = new Promise((resolve, reject) => { | ||
this.resolve = resolve; | ||
this.reject = reject; | ||
}); | ||
} | ||
} |