FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
angular.js/src/stringify.js at master · Semsemq/angular.js · GitHub
Semsemq
/
angular.js
Public
forked from
angular/angular.js
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
15
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
angular.js
/
src
/
stringify.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (31 loc) · 1.08 KB
Breadcrumbs
angular.js
/
src
/
stringify.js
Copy path
File metadata and controls
37 lines (31 loc) · 1.08 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
'use strict'
;
/* exported toDebugString */
function
serializeObject
(
obj
,
maxDepth
)
{
var
seen
=
[
]
;
// There is no direct way to stringify object until reaching a specific depth
// and a very deep object can cause a performance issue, so we copy the object
// based on this specific depth and then stringify it.
if
(
isValidObjectMaxDepth
(
maxDepth
)
)
{
// This file is also included in `angular-loader`, so `copy()` might not always be available in
// the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed.
obj
=
angular
.
copy
(
obj
,
null
,
maxDepth
)
;
}
return
JSON
.
stringify
(
obj
,
function
(
key
,
val
)
{
val
=
toJsonReplacer
(
key
,
val
)
;
if
(
isObject
(
val
)
)
{
if
(
seen
.
indexOf
(
val
)
>=
0
)
return
'...'
;
seen
.
push
(
val
)
;
}
return
val
;
}
)
;
}
function
toDebugString
(
obj
,
maxDepth
)
{
if
(
typeof
obj
===
'function'
)
{
return
obj
.
toString
(
)
.
replace
(
/
\{
[
\s
\S
]
*
$
/
,
''
)
;
}
else
if
(
isUndefined
(
obj
)
)
{
return
'undefined'
;
}
else
if
(
typeof
obj
!==
'string'
)
{
return
serializeObject
(
obj
,
maxDepth
)
;
}
return
obj
;
}
Back
|
FazBrowse Home
|
New Git URL