* Registers a listener to invoke when a promise is resolved, regardless * of whether the promise's value was successfully computed. This function * is synonymous with the finally clause in a synchronous API: * * // Synchronous API: * try { * doSynchronousWork(); * }
(promise, callback)
| 96 | * @template R |
| 97 | */ |
| 98 | async function thenFinally(promise, callback) { |
| 99 | try { |
| 100 | await Promise.resolve(promise) |
| 101 | return callback() |
| 102 | } catch (e) { |
| 103 | await callback() |
| 104 | throw e |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Calls a function for each element in an array and inserts the result into a |