-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstackman.node.txt
69 lines (54 loc) · 3.75 KB
/
stackman.node.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
┏━━━━━━━━━━━━━━┓
┃ STACKMAN ┃
┗━━━━━━━━━━━━━━┛
ALTERNATIVES (PARSING) ==> #See stacktrace.js
ALTERNATIVES (SOURCE MAP) ==> #See node-source-map-support
ALTERNATIVES (CONTEXT) ==> #See better-stack-traces
VERSION ==> #4.0.1
#Node and Chrome only (V8-specific)
┌───────────────────┐
│ NORMALIZATION │
└───────────────────┘
STACKMAN([OPTS])->STACKM #
SCALL #Normalized CALL (see Node doc)
SCALL.* #Same as CALL.*
SCALL.getModuleName()->'MODULE' #If inside a Node module, by parsing getFileName()
SCALL.getRelativeFileName()
->'FILENAME' #Like getFileName() but strips process.cwd()
SCALL.getTypeNameSafely()
->STR|null #Like getTypeName() but does not throw
SCALL.getFunctionNameSanitized()
->'TYPE.FUNC' #Returns either getFunctionName() or (getTypeName() + getMethodName()) or '<anonymous>'
SCALL.isNode()->BOOL #Is node internals
SCALL.isModule()->BOOL #Is Node module
SCALL.isApp()->BOOL #Is neither node internals nor Node module
STACKM.callsites(ERROR, [SOPTS, ] #Retrieve current stack trace as SCALL_ARR
FUNC(SCALL_ARR)) #Do it by using ERROR-CALLSITES (see its doc)
STACKM.properties(ERROR)->OBJ #Returns ERROR as plain OBJ:
# - with only values of type STR|NUM|BOOL|undefined|SYM|DATE
# - without 'stack'
┌─────────────────┐
│ SOURCE MAPS │
└─────────────────┘
SOURCE MAP ==> #Patches the following to use source maps:
# - SCALL.getFileName|LineNumber|ColumnNumber() (using "mappings")
# - SCALL.sourceContext() (using "sourceContent" instead of fetching file)
#Do by retrieving and fetching source map from sourceMappingURL (base64 date URI or normal URI)
# - cached OPTS.sourceMapCacheMax NUM (def: 100) times
SCALL.sourcemap #CONSUMER (from mozilla source-map, see its doc)
SOPTS.sourcemap #BOOL (def: true)
┌─────────────┐
│ CONTEXT │
└─────────────┘
SCALL.sourceContext #Retrieve line of code and NUM surrounding lines as CONTEXT:
([NUM, ]FUNC(ERROR, CONTEXT)) # - line STR
# - pre|post STR_ARR
#Def NUM: 5
#Do it by:
# - reading 'FILENAME' (from getFileName())
# - OPTS.fileCacheMax NUM (def: 500) fetches are cached
# - retrieving line number (from getLineNumber())
STACKM.sourceContexts(SCALL_ARR, #Call each SCALL.sourceContext()
[SOPTS, ]FUNC(ERROR,CONTEXT_ARR))#SOPTS:
# - lines NUM (def: 5)
# - inAppLines|libraryLines (def: 5): when SCALL.isApp() or not