refactor(core): Convert workflows controller to DI (no-changelog) (#8253)

This commit is contained in:
Iván Ovejero
2024-01-08 12:54:23 +01:00
committed by GitHub
parent ac1c642fdd
commit 90c065e999
10 changed files with 179 additions and 232 deletions

View File

@@ -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;
}, []);
}