Dev: Optimize console big array performance

This commit is contained in:
surunzi
2018-01-10 16:32:56 +08:00
parent edbc96dba4
commit 39f58d6888
2 changed files with 25 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ export default function getAbstract(obj, {
{
if (i > keyNum)
{
objEllipsis = '...';
objEllipsis = ', ...';
return;
}
let key = wrapKey(escapeJsonStr(name));
@@ -118,8 +118,19 @@ export default function getAbstract(obj, {
if (doStringify)
{
json = '[';
each(obj, val => parts.push(`${getAbstract(val, passOpts)}`));
json += parts.join(', ') + ']';
let len = obj.length,
arrEllipsis = '';
if (len > 100)
{
len = 100;
arrEllipsis = ', ...';
}
for (let i = 0; i < len; i++)
{
parts.push(`${getAbstract(obj[i], passOpts)}`);
}
json += parts.join(', ') + arrEllipsis + ']';
} else
{
json = wrapStr(`Array[${obj.length}]`);