n8n/packages/nodes-base/nodes/Transform/utils/utils.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
410 B
TypeScript
Raw Normal View History

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.`,
);
};