mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 01:24:05 -08:00
675ec21d33
- Split Items List node into separate nodes per action - Review node descriptions - New icons - New sections in subcategories --------- Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Deborah <deborah@starfallprojects.co.uk> Co-authored-by: Michael Kret <michael.k@radency.com>
37 lines
965 B
TypeScript
37 lines
965 B
TypeScript
import get from 'lodash/get';
|
|
import isEqual from 'lodash/isEqual';
|
|
import isObject from 'lodash/isObject';
|
|
import merge from 'lodash/merge';
|
|
import reduce from 'lodash/reduce';
|
|
import type { IDataObject, INode, INodeExecutionData } from 'n8n-workflow';
|
|
|
|
export const compareItems = (
|
|
obj: INodeExecutionData,
|
|
obj2: INodeExecutionData,
|
|
keys: string[],
|
|
disableDotNotation: boolean,
|
|
_node: INode,
|
|
) => {
|
|
let result = true;
|
|
for (const key of keys) {
|
|
if (!disableDotNotation) {
|
|
if (!isEqual(get(obj.json, key), get(obj2.json, key))) {
|
|
result = false;
|
|
break;
|
|
}
|
|
} else {
|
|
if (!isEqual(obj.json[key], obj2.json[key])) {
|
|
result = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
|
|
export const flattenKeys = (obj: IDataObject, path: string[] = []): IDataObject => {
|
|
return !isObject(obj)
|
|
? { [path.join('.')]: obj }
|
|
: reduce(obj, (cum, next, key) => merge(cum, flattenKeys(next as IDataObject, [...path, key])), {}); //prettier-ignore
|
|
};
|