(obj, maxDepth)
| 2616 | /* exported toDebugString */ |
| 2617 | |
| 2618 | function serializeObject(obj, maxDepth) { |
| 2619 | var seen = []; |
| 2620 | |
| 2621 | // There is no direct way to stringify object until reaching a specific depth |
| 2622 | // and a very deep object can cause a performance issue, so we copy the object |
| 2623 | // based on this specific depth and then stringify it. |
| 2624 | if (isValidObjectMaxDepth(maxDepth)) { |
| 2625 | // This file is also included in `angular-loader`, so `copy()` might not always be available in |
| 2626 | // the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed. |
| 2627 | obj = angular.copy(obj, null, maxDepth); |
| 2628 | } |
| 2629 | return JSON.stringify(obj, function(key, val) { |
| 2630 | val = toJsonReplacer(key, val); |
| 2631 | if (isObject(val)) { |
| 2632 | |
| 2633 | if (seen.indexOf(val) >= 0) return '...'; |
| 2634 | |
| 2635 | seen.push(val); |
| 2636 | } |
| 2637 | return val; |
| 2638 | }); |
| 2639 | } |
| 2640 | |
| 2641 | function toDebugString(obj, maxDepth) { |
| 2642 | if (typeof obj === 'function') { |
no test coverage detected