Function
makeLazyPromise
(
asyncFunc: () => PromiseLike<any>,
)
Source from the content-addressed store, hash-verified
| 83 | } |
| 84 | |
| 85 | export function makeLazyPromise( |
| 86 | asyncFunc: () => PromiseLike<any>, |
| 87 | ): PromiseLike<any> { |
| 88 | let promise: PromiseLike<any> | undefined; |
| 89 | |
| 90 | return { |
| 91 | then: (onFulfilled, onRejected) => { |
| 92 | if (promise == null) { |
| 93 | promise = asyncFunc(); |
| 94 | } |
| 95 | |
| 96 | return promise.then(onFulfilled, onRejected); |
| 97 | }, |
| 98 | }; |
| 99 | } |
Callers
nothing calls this directly
Tested by
no test coverage detected