Skip to content

Commit 54429a7

Browse files
committed
add comments to async helpers
1 parent d5b10d7 commit 54429a7

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/jsutils/after.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { isPromise } from './isPromise.js';
22
import type { PromiseOrValue } from './PromiseOrValue.js';
33

4+
/**
5+
* Async Helper Function that avoides `.then()`
6+
*
7+
* It is faster to await a promise prior to returning it from an async function
8+
* than to return a promise with `.then()`.
9+
*
10+
* see: https://github.com/tc39/proposal-faster-promise-adoption
11+
*/
412
export async function after<T, R>(
513
promise: Promise<T>,
614
onFulfilled: (value: T) => PromiseOrValue<R>,

src/jsutils/catchAfter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Async Helper Function that avoides `.then()`
3+
*
4+
* It is faster to await a promise prior to returning it from an async function
5+
* than to return a promise with `.then()`.
6+
*
7+
* see: https://github.com/tc39/proposal-faster-promise-adoption
8+
*/
19
export async function catchAfter<T, U>(
210
promise: Promise<T>,
311
onError: (error: any) => U,

src/jsutils/tryAfter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Async Helper Function that avoides `.then()`
3+
*
4+
* It is faster to await a promise prior to returning it from an async function
5+
* than to return a promise with `.then()`.
6+
*
7+
* see: https://github.com/tc39/proposal-faster-promise-adoption
8+
*/
19
export async function tryAfter<T, U, R = T>(
210
promise: Promise<T>,
311
onFulfilled: (value: T) => R,

0 commit comments

Comments
 (0)