I'm trying to loop through the consoleOuputParamsOBJ and update a record in my taskparamscompiled list of objects
Desired Output
{
"process00x00": {
"-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x00.png",
"-tr": 16,
"-tc": 16,
"-ofr": 16,
"-ofc": 16,
"-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
},
"process00x01": {
"-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x01.png",
"-tr": 16,
"-tc": 16,
"-ofr": 16,
"-ofc": 16,
"-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
},
"process00x02": {
"-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x02.png",
"-tr": 16,
"-tc": 16,
"-ofr": 16,
"-ofc": 16,
"-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
}
What i'm currently doing, the processname seems to be working since it's updating that value but the data it's using to update it with is only the last record from the taskparamscompiled dataset.
CURRENT CODE UPDATE:
var consoleOutputParamsOBJ = [{
name: '00x00',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\00x00.png'
},
{
name: '00x01',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\00x01.png'
},
{
name: '00x02',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\00x02.png'
},
{
name: '01x00',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\01x00.png'
},
{
name: '01x01',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\01x01.png'
},
{
name: '01x02',
filepath: 'D:\\Code\\UnitTest\\ConsoleApp\\1\\01x02.png'
}
]
var taskparamscompiled = {
haralick_process00x00: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
},
haralick_process00x01: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
},
haralick_process00x02: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
},
haralick_process01x00: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
},
haralick_process01x01: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
},
haralick_process01x02: {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1"'
}
}
var dynamicTaskParamsBaseOBJ = {
'-i': '',
'-tr': 16,
'-tc': 16,
'-ofr': 16,
'-ofc': 16,
'-outfile': '"D:\\Code\\UnitTest\\ConsoleApp\\HaralickProcess\\1"'
}
var dynamicTaskNameBaseOBJ = 'haralick_process'
var taskparamscompiled = consoleOutputParamsOBJ.reduce(
(accumulator, elem) => {
const taskname = dynamicTaskNameBaseOBJ + elem.name;
return {
...accumulator,
[taskname]: dynamicTaskParamsBaseOBJ,
};
}, {}
);
consoleOutputParamsOBJ.forEach((obj) => {
var processname = dynamicTaskNameBaseOBJ + obj.name;
filepath = obj.filepath;
taskparamscompiled[processname]['-i'] = filepath;
});
console.log('consoleOutputParamsOBJ::', consoleOutputParamsOBJ, ' \n taskparamscompiled::', taskparamscompiled);