n8n/packages/nodes-base/nodes/Transform/utils/utils.ts
Elias Meire 675ec21d33
feat: Data transformation nodes and actions in Nodes Panel (#7760)
- 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>
2023-12-08 11:40:05 +01:00

15 lines
410 B
TypeScript

export const prepareFieldsArray = (fields: string | string[], fieldName = 'Fields') => {
if (typeof fields === 'string') {
return fields
.split(',')
.map((entry) => entry.trim())
.filter((entry) => entry !== '');
}
if (Array.isArray(fields)) {
return fields;
}
throw new Error(
`The \'${fieldName}\' parameter must be a string of fields separated by commas or an array of strings.`,
);
};