const array = ['part1-item1', 'part1-item2', 'part2-item1', 'part3-item1']
{
part1: ['item1', 'item2'],
part2: ['item1'],
part3: ['item1']
}
arr.reduce((acc,rec) => {
const [devId, paramId] = rec.split('-')
if (!acc[devId]) {
return {...acc, [devId]: [paramId]}
} else {
}
}, {})
<code>