1
- export interface QuansyncInputObject < Return , Args extends any [ ] > {
2
- name ?: string
3
- sync : ( ...args : Args ) => Return
4
- async : ( ...args : Args ) => Promise < Return >
5
- }
6
-
7
- export type QuansyncGeneratorFn < Return , Args extends any [ ] >
8
- = ( ( ...args : Args ) => QuansyncGenerator < Return > )
9
-
10
- export type QuansyncInput < Return , Args extends any [ ] > =
11
- | QuansyncInputObject < Return , Args >
12
- | QuansyncGeneratorFn < Return , Args >
13
-
14
- export type QuansyncGenerator < Return = any , Yield = unknown > =
15
- Generator < Yield , Return , Awaited < Yield > > & { __quansync ?: true }
16
-
17
- export type QuansyncAwaitableGenerator < Return = any , Yield = unknown > =
18
- QuansyncGenerator < Return , Yield > & Promise < Return >
19
-
20
- /**
21
- * "Superposition" function that can be consumed in both sync and async contexts.
22
- */
23
- export type QuansyncFn < Return = any , Args extends any [ ] = [ ] > =
24
- ( ( ...args : Args ) => QuansyncAwaitableGenerator < Return > )
25
- & {
26
- sync : ( ...args : Args ) => Return
27
- async : ( ...args : Args ) => Promise < Return >
28
- }
1
+ import type { QuansyncAwaitableGenerator , QuansyncFn , QuansyncGenerator , QuansyncGeneratorFn , QuansyncInput , QuansyncInputObject } from './types'
29
2
3
+ export const GET_IS_ASYNC = Symbol . for ( 'quansync.getIsAsync' )
30
4
const ERROR_PROMISE_IN_SYNC = '[Quansync] Yielded an unexpected promise in sync context'
31
5
32
6
function isThenable < T > ( value : any ) : value is Promise < T > {
@@ -39,8 +13,6 @@ function isQuansyncGenerator<T>(value: any): value is QuansyncGenerator<T> {
39
13
return isGenerator ( value ) && '__quansync' in value
40
14
}
41
15
42
- export const GET_IS_ASYNC = Symbol . for ( 'quansync.getIsAsync' )
43
-
44
16
function fromObject < Return , Args extends any [ ] > (
45
17
options : QuansyncInputObject < Return , Args > ,
46
18
) : QuansyncFn < Return , Args > {
0 commit comments