+ [task#127427] add logic for flattenData func.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user