FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stackframe/dist/stackframe.js at patch-1 · caub/stackframe · GitHub
caub
/
stackframe
Public
forked from
stacktracejs/stackframe
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
stackframe
/
dist
/
stackframe.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
135 lines (118 loc) · 4.65 KB
Breadcrumbs
stackframe
/
dist
/
stackframe.js
Copy path
File metadata and controls
135 lines (118 loc) · 4.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
(
function
(
root
,
factory
)
{
'use strict'
;
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
define
(
'stackframe'
,
[
]
,
factory
)
;
}
else
if
(
typeof
exports
===
'object'
)
{
module
.
exports
=
factory
(
)
;
}
else
{
root
.
StackFrame
=
factory
(
)
;
}
}
(
this
,
function
(
)
{
'use strict'
;
function
_isNumber
(
n
)
{
return
!
isNaN
(
parseFloat
(
n
)
)
&&
isFinite
(
n
)
;
}
function
_capitalize
(
str
)
{
return
str
.
charAt
(
0
)
.
toUpperCase
(
)
+
str
.
substring
(
1
)
;
}
function
_getter
(
p
)
{
return
function
(
)
{
return
this
[
p
]
;
}
;
}
var
booleanProps
=
[
'isConstructor'
,
'isEval'
,
'isNative'
,
'isToplevel'
]
;
var
numericProps
=
[
'columnNumber'
,
'lineNumber'
]
;
var
stringProps
=
[
'fileName'
,
'functionName'
,
'source'
]
;
var
arrayProps
=
[
'args'
]
;
var
props
=
booleanProps
.
concat
(
numericProps
,
stringProps
,
arrayProps
)
;
function
StackFrame
(
obj
)
{
if
(
obj
instanceof
Object
)
{
for
(
var
i
=
0
;
i
<
props
.
length
;
i
++
)
{
if
(
obj
.
hasOwnProperty
(
props
[
i
]
)
&&
obj
[
props
[
i
]
]
!==
undefined
)
{
this
[
'set'
+
_capitalize
(
props
[
i
]
)
]
(
obj
[
props
[
i
]
]
)
;
}
}
}
}
StackFrame
.
prototype
=
{
getArgs
:
function
(
)
{
return
this
.
args
;
}
,
setArgs
:
function
(
v
)
{
if
(
Object
.
prototype
.
toString
.
call
(
v
)
!==
'[object Array]'
)
{
throw
new
TypeError
(
'Args must be an Array'
)
;
}
this
.
args
=
v
;
}
,
getEvalOrigin
:
function
(
)
{
return
this
.
evalOrigin
;
}
,
setEvalOrigin
:
function
(
v
)
{
if
(
v
instanceof
StackFrame
)
{
this
.
evalOrigin
=
v
;
}
else
if
(
v
instanceof
Object
)
{
this
.
evalOrigin
=
new
StackFrame
(
v
)
;
}
else
{
throw
new
TypeError
(
'Eval Origin must be an Object or StackFrame'
)
;
}
}
,
toString
:
function
(
)
{
var
functionName
=
this
.
getFunctionName
(
)
||
'{anonymous}'
;
var
args
=
'('
+
(
this
.
getArgs
(
)
||
[
]
)
.
join
(
','
)
+
')'
;
var
fileName
=
this
.
getFileName
(
)
?
(
'@'
+
this
.
getFileName
(
)
)
:
''
;
var
lineNumber
=
_isNumber
(
this
.
getLineNumber
(
)
)
?
(
':'
+
this
.
getLineNumber
(
)
)
:
''
;
var
columnNumber
=
_isNumber
(
this
.
getColumnNumber
(
)
)
?
(
':'
+
this
.
getColumnNumber
(
)
)
:
''
;
return
functionName
+
args
+
fileName
+
lineNumber
+
columnNumber
;
}
}
;
StackFrame
.
fromString
=
function
StackFrame$$fromString
(
str
)
{
var
argsStartIndex
=
str
.
indexOf
(
'('
)
;
var
argsEndIndex
=
str
.
lastIndexOf
(
')'
)
;
var
functionName
=
str
.
substring
(
0
,
argsStartIndex
)
;
var
args
=
str
.
substring
(
argsStartIndex
+
1
,
argsEndIndex
)
.
split
(
','
)
;
var
locationString
=
str
.
substring
(
argsEndIndex
+
1
)
;
if
(
locationString
.
indexOf
(
'@'
)
===
0
)
{
var
parts
=
/
@
(
.
+
?
)
(?:
:
(
\d
+
)
)
?
(?:
:
(
\d
+
)
)
?
$
/
.
exec
(
locationString
,
''
)
;
var
fileName
=
parts
[
1
]
;
var
lineNumber
=
parts
[
2
]
;
var
columnNumber
=
parts
[
3
]
;
}
return
new
StackFrame
(
{
functionName
:
functionName
,
args
:
args
||
undefined
,
fileName
:
fileName
,
lineNumber
:
lineNumber
||
undefined
,
columnNumber
:
columnNumber
||
undefined
}
)
;
}
;
for
(
var
i
=
0
;
i
<
booleanProps
.
length
;
i
++
)
{
StackFrame
.
prototype
[
'get'
+
_capitalize
(
booleanProps
[
i
]
)
]
=
_getter
(
booleanProps
[
i
]
)
;
StackFrame
.
prototype
[
'set'
+
_capitalize
(
booleanProps
[
i
]
)
]
=
(
function
(
p
)
{
return
function
(
v
)
{
this
[
p
]
=
Boolean
(
v
)
;
}
;
}
)
(
booleanProps
[
i
]
)
;
}
for
(
var
j
=
0
;
j
<
numericProps
.
length
;
j
++
)
{
StackFrame
.
prototype
[
'get'
+
_capitalize
(
numericProps
[
j
]
)
]
=
_getter
(
numericProps
[
j
]
)
;
StackFrame
.
prototype
[
'set'
+
_capitalize
(
numericProps
[
j
]
)
]
=
(
function
(
p
)
{
return
function
(
v
)
{
if
(
!
_isNumber
(
v
)
)
{
throw
new
TypeError
(
p
+
' must be a Number'
)
;
}
this
[
p
]
=
Number
(
v
)
;
}
;
}
)
(
numericProps
[
j
]
)
;
}
for
(
var
k
=
0
;
k
<
stringProps
.
length
;
k
++
)
{
StackFrame
.
prototype
[
'get'
+
_capitalize
(
stringProps
[
k
]
)
]
=
_getter
(
stringProps
[
k
]
)
;
StackFrame
.
prototype
[
'set'
+
_capitalize
(
stringProps
[
k
]
)
]
=
(
function
(
p
)
{
return
function
(
v
)
{
this
[
p
]
=
String
(
v
)
;
}
;
}
)
(
stringProps
[
k
]
)
;
}
return
StackFrame
;
}
)
)
;
Back
|
FazBrowse Home
|
New Git URL