mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Convert workflows controller to DI (no-changelog) (#8253)
This commit is contained in:
@@ -77,3 +77,23 @@ export function isObjectLiteral(item: unknown): item is { [key: string]: string
|
||||
export function removeTrailingSlash(path: string) {
|
||||
return path.endsWith('/') ? path.slice(0, -1) : path;
|
||||
}
|
||||
|
||||
// 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