-
-
Notifications
You must be signed in to change notification settings - Fork 567
/
utils.ts
41 lines (38 loc) 路 859 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { types } from '@babel/core'
export function isAtom(
t: typeof types,
callee: babel.types.Expression | babel.types.V8IntrinsicIdentifier
) {
if (t.isIdentifier(callee) && atomFunctionNames.includes(callee.name)) {
return true
}
if (t.isMemberExpression(callee)) {
const { property } = callee
if (t.isIdentifier(property) && atomFunctionNames.includes(property.name)) {
return true
}
}
return false
}
const atomFunctionNames = [
'atom',
'atomFamily',
'atomWithDefault',
'atomWithHash',
'atomWithImmer',
'atomWithInfiniteQuery',
'atomWithMachine',
'atomWithMutation',
'atomWithObservable',
'atomWithProxy',
'atomWithQuery',
'atomWithReducer',
'atomWithReset',
'atomWithSubscription',
'atomWithStorage',
'atomWithStore',
'freezeAtom',
'loadable',
'selectAtom',
'splitAtom',
]