const options = {
{
id: 1,
name: "ГОСТ",
slug: "gost",
values: {
{
id: 10,
value: "SOMEVALUE"
}
}
}
}
const mapOptions = (options, values) => option.map(({ option }) => {
const usedValues = new Set();
return {
id: option.id,
name: option.name,
slug: option.slug,
values: values.reduce((acc, { id, value }) => {
if (id === option.id && !usedValues.has(value)) {
usedValues.add(value);
acc.push({ id, value });
}
return acc;
}, [])
};
});
console.log(mapOptions(options, option_values));