import { Container } from 'typedi'; import { License } from '@/License'; export function isSharingEnabled(): boolean { return Container.get(License).isSharingEnabled(); } // return the difference between two arrays export function rightDiff( [arr1, keyExtractor1]: [T1[], (item: T1) => string], [arr2, keyExtractor2]: [T2[], (item: T2) => string], ): T2[] { // create map { itemKey => true } for fast lookup for diff const keyMap = arr1.reduce<{ [key: string]: true }>((map, item) => { map[keyExtractor1(item)] = true; return map; }, {}); // diff against map return arr2.reduce((acc, item) => { if (!keyMap[keyExtractor2(item)]) { acc.push(item); } return acc; }, []); }