forked from ehmicky/Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecast.node.txt
More file actions
54 lines (47 loc) · 3.36 KB
/
recast.node.txt
File metadata and controls
54 lines (47 loc) · 3.36 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
┏━━━━━━━━━━━━┓
┃ RECAST ┃
┗━━━━━━━━━━━━┛
ALTERNATIVES ==> # - recast (preferred)
# - escodegen: not maintained anymore
VERSION ==> #0.12.5
#Serialize JavaScript from AST
#Also do parsing (forwarding to Esprima)
AST FORMAT ==> #ESTree, Esprima flavor.
parse('JS'[, OPTS])->NODE #Forward to ESPRIMA.parse()
#Automatically use OPTS:
# - jsx true, ecmaVersion 6, sourceType 'module'
# - loc true, locations true, comment true
#Can specify OPTS:
# - range BOOL (def: false)
# - tabWidth NUM (def: same as source)
# - sourceFileName 'FILE': for source maps
# - tolerant BOOL (def: true): do not throw on non-fatal errors
[pretty]print(NODE[, OPTS])->OBJ #Serialize AST to OBJ.code 'JS'
#OPTS:
# - tabWidth NUM (def: 4)
# - useTabs BOOL (def: false)
# - reuseWhitespaces BOOL (def: true): do not change whitespaces
# - lineTerminator STR (def: OS.EOL)
# - wrapColumn NUM (def: 74): line width
# - quote "auto", "single" or "double" (def)
# - trailingCommas BOOL (def: false) or { objects|arrays|parameters BOOL }
# - objectCurlySpacing BOOL (def: false): space inside {}
# - arrayBracketSpacing BOOL (def: false): space inside []
# - arrowParensAlways BOOL (def: false): (VAL) => {} not VAL => {}
# - flowObjectCommas BOOL (def: false): use , (true, def) or ; in Flow comments
#Pretty prints:
# - 'pretty': everything
# - no 'pretty': only what was changed
# - i.e. print(parse('JS')) guaranteed to === 'JS', including comments and whitespaces
SOURCE MAPS ==> #OBJ.map SOURCE_MAP:
# - version|sourcesContent|mappings|names
# - file 'FILE': from OPTS.sourceMapName
# - sources 'FILE'_ARR: from OPTS.sourceFileName
# - sourceRoot STR: from OPTS.sourceRoot
#OPTS:
# - sourceMapName STR
# - sourceRoot STR
# - inputSourceMap OBJ:
# - previous source map to reuse (compose with new one)
# - must be previous print() result.map
#Not possible with prettyPrint()