export type Compare = {
[x: string]: any
channelid: number,
childrenHash: Child[]
}
export type Child = {
id: number, hash: string
}
export const comparsion = (data: Compare) => {
const res = data?.map((n: { childrenHash: any[] }) => {
const ids = Object.values(n.childrenHash.reduce((acc, m) => ((acc[m.hash] ??= []).push(m.id), acc), {})).filter(m => m.length > 1);
return {
...n,
childrenHash: ids.length ? ids : null,
};
})
return res
}