Tofu/app/tools/text/splitIngredientLine.js

8 lines
265 B
JavaScript

// Reads the free ingredient line typed by the user: comma separated names.
export function splitIngredientLine(line) {
if (typeof line !== 'string') return []
return line
.split(',')
.map((part) => part.trim())
.filter((part) => part.length > 0)
}