refactor(core): Convert workflows controller to DI (no-changelog) (#8253)
This commit is contained in:
@@ -4,23 +4,3 @@ import { License } from '@/License';
|
||||
export function isSharingEnabled(): boolean {
|
||||
return Container.get(License).isSharingEnabled();
|
||||
}
|
||||
|
||||
// return the difference between two arrays
|
||||
export function rightDiff<T1, T2>(
|
||||
[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<T2[]>((acc, item) => {
|
||||
if (!keyMap[keyExtractor2(item)]) {
|
||||
acc.push(item);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user