File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { isPromise } from './isPromise.js' ;
2
2
import type { PromiseOrValue } from './PromiseOrValue.js' ;
3
3
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
+ */
4
12
export async function after < T , R > (
5
13
promise : Promise < T > ,
6
14
onFulfilled : ( value : T ) => PromiseOrValue < R > ,
Original file line number Diff line number Diff line change
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
+ */
1
9
export async function catchAfter < T , U > (
2
10
promise : Promise < T > ,
3
11
onError : ( error : any ) => U ,
Original file line number Diff line number Diff line change
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
+ */
1
9
export async function tryAfter < T , U , R = T > (
2
10
promise : Promise < T > ,
3
11
onFulfilled : ( value : T ) => R ,
You can’t perform that action at this time.
0 commit comments