Skip to content

Commit

Permalink
add comments to async helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Dec 16, 2022
1 parent 044941f commit 025f26e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/jsutils/after.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { isPromise } from './isPromise.js';
import type { PromiseOrValue } from './PromiseOrValue.js';

/**
* Async Helper Function that avoides `.then()`
*
* It is faster to await a promise prior to returning it from an async function
* than to return a promise with `.then()`.
*
* see: https://github.com/tc39/proposal-faster-promise-adoption
*/
export async function after<T, R>(
promise: Promise<T>,
onFulfilled: (value: T) => PromiseOrValue<R>,
Expand Down
8 changes: 8 additions & 0 deletions src/jsutils/catchAfter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Async Helper Function that avoides `.then()`
*
* It is faster to await a promise prior to returning it from an async function
* than to return a promise with `.then()`.
*
* see: https://github.com/tc39/proposal-faster-promise-adoption
*/
export async function catchAfter<T, U>(
promise: Promise<T>,
onError: (error: any) => U,
Expand Down
8 changes: 8 additions & 0 deletions src/jsutils/tryAfter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Async Helper Function that avoides `.then()`
*
* It is faster to await a promise prior to returning it from an async function
* than to return a promise with `.then()`.
*
* see: https://github.com/tc39/proposal-faster-promise-adoption
*/
export async function tryAfter<T, U, R = T>(
promise: Promise<T>,
onFulfilled: (value: T) => R,
Expand Down

0 comments on commit 025f26e

Please sign in to comment.