import { split } from '@lib' ; export type AllergenicProduct = { ingredients : string [ ] ; allergens : string [ ] ; } ; export const parse = ( input ) : AllergenicProduct [ ] => { const entries = [ ] ; for ( const line of split ( input ) ) { const [ rawIngredients , rawAllergens ] = line . split ( ' (contains ' ) ; const ingredients = rawIngredients . split ( ' ' ) ; const allergens = rawAllergens . substring ( 0 , rawAllergens . length - 1 ) . split ( ', ' ) ; entries . push ( { ingredients , allergens } ) ; } return entries ; } ;