Using Object-Scan JS lib, want to find all the grand parent elements that have key "referenceField". Any help is much appreciated.
const find = (item, input) => objectScan(['**'], {
abort: true,
rtn: 'parent',
filterFn: ({
key
}) => key === item.key
})(input);
console.log(find('referenceField', data));
Object-scan was somehow not returning grand parent using gparent option, but based on the assumption that your properties will always have the same nesting, you can take help of parents option and change your code to this-
const find = (item, input) => objectScan([`**.${item}`], {
abort: true,
rtn: 'parents'
})(input)[1];