(obj, maxDepth)
| 2676 | /* exported toDebugString */ |
| 2677 | |
| 2678 | function serializeObject(obj, maxDepth) { |
| 2679 | var seen = []; |
| 2680 | |
| 2681 | // There is no direct way to stringify object until reaching a specific depth |
| 2682 | // and a very deep object can cause a performance issue, so we copy the object |
| 2683 | // based on this specific depth and then stringify it. |
| 2684 | if (isValidObjectMaxDepth(maxDepth)) { |
| 2685 | // This file is also included in `angular-loader`, so `copy()` might not always be available in |
| 2686 | // the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed. |
| 2687 | obj = angular.copy(obj, null, maxDepth); |
| 2688 | } |
| 2689 | return JSON.stringify(obj, function(key, val) { |
| 2690 | val = toJsonReplacer(key, val); |
| 2691 | if (isObject(val)) { |
| 2692 | |
| 2693 | if (seen.indexOf(val) >= 0) return '...'; |
| 2694 | |
| 2695 | seen.push(val); |
| 2696 | } |
| 2697 | return val; |
| 2698 | }); |
| 2699 | } |
| 2700 | |
| 2701 | function toDebugString(obj, maxDepth) { |
| 2702 | if (typeof obj === 'function') { |
no test coverage detected