Assuming I have this deeply nested object
let obj = {
comp: "el",
type: "ele",
children: [
{
children: [
{
text: "text",
children: [],
uid: "-5zIANJjCz-qU0MNcf5E1",
},
{
text:"text",
children: [],
uid: "bpeVj4NaD_Io3WP7V0v91"
}
],
uid: "ZygtUliVsFbFpbmHv5yp9"
},
{
children: [
{
text: "text",
children: [],
uid: "qmw59v1BVRMEuM8r9VvQp",
},
{
text: "text. ",
children: [],
uid: "q-QeWlEnKvVTjD0dPRXCu"
}
],
uid: "rp_gURLFIgd1n7bn-pRhn"
},
{
children: [
{
text: "text",
children: [],
uid: "8gIytZ52tq0mqiVAhAJLN",
},
{
text: "text",
children: [],
uid: "q-QeeWlEnKvVTjD0dPRXCu"
}
],
uid: "M3hqA-Rp1wQz60IVdIGUX"
}
],
uid: "M4JBL9SoOOLo5iQSb5M_P"
};
How would I go about getting an array of all uid values?
Currently I am using object scan
https://github.com/blackflux/object-scan
const find = (data, needle) => objectScan([needle], { rtn: "value" })(data);
const allIds = find(obj, "**.uid");
This works really well but I am curious how this could be achieved with recursion.