М
Size: a a a
М
R
М
М
М
gk
ЕИ
NT
gk
gk
gk
NT
NT
gk
NT
display: block;
М
function someFunc2(data) {Держи без кеша. Меньше кода.
return data.reduce((acc, item) => {
let search = acc.findIndex((el) => el["itemType"] === item["itemType"] && el["position"] === item["position"]);
if (search >= 0) {
acc[search] = { ...acc[search], content: `${acc[search]["content"]}:${item["content"]}` };
} else {
acc.push(item);
}
return acc;
}, []);
}
someFunc2(parsedLines);
function someFunc(data) {
const cache = {};
return data.reduce((acc, item) => {
const chechCacheID = cache[item["itemType"]] && cache[item["itemType"]][item["position"]];
if (chechCacheID) {
acc[chechCacheID] = { ...acc[chechCacheID], content: `${acc[chechCacheID]["content"]}:${item["content"]}` };
} else {
acc.push(item);
cache[item["itemType"]] = { ...cache[item["itemType"]], [item["position"]]: acc.length - 1 };
}
return acc;
}, []);
}
М
NT