Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 1x 2x 2x 2x 2x 5x 5x 4x 1x 2x | /**
* Main runner function for grocery list project
*
* @module main
*/
const groceries = require("./groceries.js");
const general = require("./general.js");
const meal = require("./meal.js")
'use strict';
module.exports = {
/**
* Takes a file with a list of meals as an input and returns ingredients with quantities as an Object
*
* @param mealsFileName {string} Filepath to list of meals. Meals are expected to be separated by a new line (\n).
* @returns {Promise<{Object}>} Object where Key: Ingredient, Value: Quantity
*/
main: async function(mealsFileName) {
let meals_from_list = general.readFileIntoArray(mealsFileName);
let ingredients = {};
let missed_meals = [];
for (let meal_from_list of meals_from_list) {
let mealData = await groceries.getMealData(meal_from_list);
if (mealData instanceof meal) {
ingredients = general.concatObjectMerge(ingredients, mealData.ingredients);
} else {
missed_meals.push(meal_from_list);
}
}
return [ingredients, missed_meals];
}
} |