(obj, maxDepth)
| 2641 | /* exported toDebugString */ |
| 2642 | |
| 2643 | function serializeObject(obj, maxDepth) { |
| 2644 | var seen = []; |
| 2645 | |
| 2646 | // There is no direct way to stringify object until reaching a specific depth |
| 2647 | // and a very deep object can cause a performance issue, so we copy the object |
| 2648 | // based on this specific depth and then stringify it. |
| 2649 | if (isValidObjectMaxDepth(maxDepth)) { |
| 2650 | // This file is also included in `angular-loader`, so `copy()` might not always be available in |
| 2651 | // the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed. |
| 2652 | obj = angular.copy(obj, null, maxDepth); |
| 2653 | } |
| 2654 | return JSON.stringify(obj, function(key, val) { |
| 2655 | val = toJsonReplacer(key, val); |
| 2656 | if (isObject(val)) { |
| 2657 | |
| 2658 | if (seen.indexOf(val) >= 0) return '...'; |
| 2659 | |
| 2660 | seen.push(val); |
| 2661 | } |
| 2662 | return val; |
| 2663 | }); |
| 2664 | } |
| 2665 | |
| 2666 | function toDebugString(obj, maxDepth) { |
| 2667 | if (typeof obj === 'function') { |
no test coverage detected