I use the following code to find if there is duplicate value in property path,This code is working!
return new Promise((resolve, reject) => {
var data = [];
Parser.parse()
//configObj is the value from the screen shot
.then((configObj) => {
configObj.forEach((providers) => {
_.each(providers, (provider) => {
_.each(provider, (entry) => {
for (var prop in entry) {
if (_inArray(entry[prop].path, data)) {
return reject(new Error(`Duplicate path ${entry[prop].path}`));
}
data.push(entry[prop].path);
}
})
})
})
resolve("validObject");
}, err => {
reject(err);
});
This is the object configObj and as you can see I need to find duplicate in object 'replace' and object 'save' for the value in field 'path' if they have the same value reject with error otherwise resolve the promise,is there is more elegant way to write it?

in this example the path is diffrent (test2 & command1) but it can be the same