Skip to content

Commit 5d1e5be

Browse files
committed
refactor: rename get is async flag
1 parent 2f5c2e8 commit 5d1e5be

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ function isGenerator<T>(value: any): value is Generator<T> {
3333
return value && typeof value === 'object' && typeof value[Symbol.iterator] === 'function'
3434
}
3535

36-
const START_FLAG = Symbol.for('quansync:start')
36+
const GET_IS_ASYNC = Symbol.for('quansync.getIsAsync')
3737

3838
function fromObject<Return, Args extends any[]>(
3939
options: QuansyncInputObject<Return, Args>,
4040
): QuansyncFn<Return, Args> {
4141
const generator = function* (...args: Args): QuansyncGenerator<Return, any> {
42-
const isAsync = yield START_FLAG
42+
const isAsync = yield GET_IS_ASYNC
4343
if (isAsync)
4444
return yield options.async(...args)
4545
return options.sync(...args)
@@ -66,7 +66,7 @@ function fromPromise<T>(promise: Promise<T> | T): QuansyncFn<T, []> {
6666
}
6767

6868
function unwrapYield(value: any, isAsync?: boolean): any {
69-
if (value === START_FLAG)
69+
if (value === GET_IS_ASYNC)
7070
return isAsync
7171
if (!isAsync && isThenable(value))
7272
throw new Error(ERROR_PROMISE_IN_SYNC)
@@ -125,7 +125,7 @@ export function quansync<Return, Args extends any[] = []>(
125125
export function quansyncMacro<Return, Args extends any[] = []>(
126126
options: QuansyncInput<Return, Args> | ((...args: Args) => Promise<Return> | Return),
127127
): QuansyncFn<Return, Args> {
128-
return quansync(options as any) as any
128+
return quansync(options as any)
129129
}
130130

131131
/**

0 commit comments

Comments
 (0)