24cd70058d
Fix any place that compares with `undefined` to use `isUndefined` and `isDefined` instead. Closes #4365 Closes #12831
30 lines
583 B
JavaScript
30 lines
583 B
JavaScript
'use strict';
|
|
|
|
/* global: toDebugString: true */
|
|
|
|
function serializeObject(obj) {
|
|
var seen = [];
|
|
|
|
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) {
|
|
if (typeof obj === 'function') {
|
|
return obj.toString().replace(/ \{[\s\S]*$/, '');
|
|
} else if (isUndefined(obj)) {
|
|
return 'undefined';
|
|
} else if (typeof obj !== 'string') {
|
|
return serializeObject(obj);
|
|
}
|
|
return obj;
|
|
}
|