mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(Spreadsheet File Node): Reduce memory usage when loading CSV files (#7095)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
committed by
GitHub
parent
2f647974f4
commit
689a77cc87
@@ -264,3 +264,30 @@ export function getResolvables(expression: string) {
|
||||
|
||||
return resolvables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an object with deep data
|
||||
*
|
||||
* @param {IDataObject} data The object to flatten
|
||||
*/
|
||||
export function flattenObject(data: IDataObject) {
|
||||
const returnData: IDataObject = {};
|
||||
for (const key1 of Object.keys(data)) {
|
||||
if (data[key1] !== null && typeof data[key1] === 'object') {
|
||||
if (data[key1] instanceof Date) {
|
||||
returnData[key1] = data[key1]?.toString();
|
||||
continue;
|
||||
}
|
||||
const flatObject = flattenObject(data[key1] as IDataObject);
|
||||
for (const key2 in flatObject) {
|
||||
if (flatObject[key2] === undefined) {
|
||||
continue;
|
||||
}
|
||||
returnData[`${key1}.${key2}`] = flatObject[key2];
|
||||
}
|
||||
} else {
|
||||
returnData[key1] = data[key1];
|
||||
}
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user