File size: 300 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 |
// @flow
export const deduplicateChildren = (
array: Array<any>,
prop: string
): Array<any> => {
if (!array || !Array.isArray(array) || array.length === 0) return array;
return array.filter((obj, pos, arr) => {
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos;
});
};
|