Looking for an alternative method to achieve the same functionality as flatmap in JavaScript with lower ES5 version for the following mapping.
const b = [{
"errorname": [{
"name": "Error 01",
"desc_1": "Test: 01",
"desc_2": "Testing"
}, {
"name": "Error 03",
"desc_1": "Test: 03",
"desc_2": "Testing"
}],
}, {
"errorname": [{
"name": "Error 02",
"desc_1": "Test: 02",
"desc_2": "Testing"
}, {
"name": "Error 09",
"desc_1": "Test: 09",
"desc_2": "Testing"
} ]
}];
var errorMap = generateErrorMap(b);
function generateErrorMap(arr){
var newArray = [];
arr.forEach(function(elem){
elem.errorname.forEach(function(error){
var tempObj = {};
tempObj[error.name] = {desc_1: error.desc_1, desc_2: error.desc_2};
newArray.push(tempObj);
});
});
return newArray;
}
console.log(errorMap)
.as-console-wrapper {
max-height: 100% !important;
top: 0;
}
Exploring options for ES5 compatibility with similar operations. The application is accessed using an electron app that does not support ES9.