+ [task#127427] add logic for flattenData func.

This commit is contained in:
wangzemei
2024-09-13 09:29:16 +08:00
committed by 刘刚
parent 7519b659b2
commit 90b579afd0
+16
View File
@@ -299,6 +299,22 @@ function flattenData(data)
const result = [];
const stack = data.slice();
while (stack.length > 0)
{
const item = stack.pop();
if(typeof item === 'object' && item !== null && Object.prototype.toString.call(item) === '[object Array]')
{
for(let i = item.length - 1; i >= 0; i--)
{
stack.push(item[i]);
}
}
else
{
result.push(item);
}
}
return result;
}