/
githubmirror
/
angular.js
Обзор
Документация
Войти
/
githubmirror
/
angular.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.6.3
src/stringify.js
35 строк
912 B
mohamed amr
feat(errorHandlingConfig): make the depth for object stringification in errors configurable
08 фев 2017, 20:06
08 фев 2017, 20:06
4a5eaf7
Код
Авторство
О чём код?
'use strict'; /* global toDebugString: true */ 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)) { obj = 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; }