@@ -33,13 +33,13 @@ function isGenerator<T>(value: any): value is Generator<T> {
33
33
return value && typeof value === 'object' && typeof value [ Symbol . iterator ] === 'function'
34
34
}
35
35
36
- const START_FLAG = Symbol . for ( 'quansync:start ' )
36
+ const GET_IS_ASYNC = Symbol . for ( 'quansync.getIsAsync ' )
37
37
38
38
function fromObject < Return , Args extends any [ ] > (
39
39
options : QuansyncInputObject < Return , Args > ,
40
40
) : QuansyncFn < Return , Args > {
41
41
const generator = function * ( ...args : Args ) : QuansyncGenerator < Return , any > {
42
- const isAsync = yield START_FLAG
42
+ const isAsync = yield GET_IS_ASYNC
43
43
if ( isAsync )
44
44
return yield options . async ( ...args )
45
45
return options . sync ( ...args )
@@ -66,7 +66,7 @@ function fromPromise<T>(promise: Promise<T> | T): QuansyncFn<T, []> {
66
66
}
67
67
68
68
function unwrapYield ( value : any , isAsync ?: boolean ) : any {
69
- if ( value === START_FLAG )
69
+ if ( value === GET_IS_ASYNC )
70
70
return isAsync
71
71
if ( ! isAsync && isThenable ( value ) )
72
72
throw new Error ( ERROR_PROMISE_IN_SYNC )
@@ -125,7 +125,7 @@ export function quansync<Return, Args extends any[] = []>(
125
125
export function quansyncMacro < Return , Args extends any [ ] = [ ] > (
126
126
options : QuansyncInput < Return , Args > | ( ( ...args : Args ) => Promise < Return > | Return ) ,
127
127
) : QuansyncFn < Return , Args > {
128
- return quansync ( options as any ) as any
128
+ return quansync ( options as any )
129
129
}
130
130
131
131
/**
0 commit comments