mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
improved loops in getValuesAtPath method
This commit is contained in:
parent
6a2bc0188c
commit
991864cdd3
1 changed files with 5 additions and 7 deletions
|
@ -36,11 +36,11 @@ export default function (json, path) {
|
|||
if (pathIndex >= path.length) {
|
||||
if (element) {
|
||||
if (element.constructor === Array) {
|
||||
for (let i = 0; i < element.length; i++) {
|
||||
if (element[i]) {
|
||||
values.push(element[i]);
|
||||
element.forEach(child => {
|
||||
if (child) {
|
||||
values.push(child);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
values.push(element);
|
||||
}
|
||||
|
@ -50,9 +50,7 @@ export default function (json, path) {
|
|||
getValues(element[path[pathIndex]], pathIndex + 1);
|
||||
}
|
||||
} else if (element.constructor === Array) {
|
||||
for (let childi = 0; childi < element.length; childi++) {
|
||||
getValues(element[childi], pathIndex);
|
||||
}
|
||||
element.forEach(child => getValues(child, pathIndex));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue