File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ export function toGenerator<T>(promise: Promise<T> | QuansyncGenerator<T> | T):
142
142
/**
143
143
* @returns `true` if the current context is async, `false` otherwise.
144
144
*/
145
- export function * getIsAsync ( ) : Generator < typeof GET_IS_ASYNC , boolean , unknown > {
146
- return ! ! ( yield GET_IS_ASYNC )
147
- }
145
+ export const getIsAsync = quansync ( {
146
+ async : ( ) => Promise . resolve ( true ) ,
147
+ sync : ( ) => false ,
148
+ } )
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ it('call onYield hook', async () => {
285
285
286
286
it ( 'getIsAsync' , async ( ) => {
287
287
const fn = quansync ( function * ( ) {
288
- const isAsync : boolean = yield * getIsAsync ( )
288
+ const isAsync = ( yield getIsAsync ( ) ) as boolean
289
289
return isAsync
290
290
} )
291
291
await expect ( fn . async ( ) ) . resolves . toBe ( true )
You can’t perform that action at this time.
0 commit comments