-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubstitutionList.js
40 lines (32 loc) · 1.04 KB
/
SubstitutionList.js
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
35
36
37
38
39
40
SUBSTITUTIONS = {};
EQUALS = {};
function setListEqual(name, amountList){
let ingredientList = [];
amountList.forEach(unit => {
var unitParse = parseUnit(unit);
ingredientList.push(new Ingredient(name, unitParse[0], unitParse[1]));
});
EQUALS[name] = new Substitutes(ingredientList);
}
function setSubstitute(ingredientFrom, ingredientTo){
if(ingredientFrom.name in SUBSTITUTIONS){
SUBSTITUTIONS[ingredientFrom.name].add(ingredientFrom, ingredientTo);
}
else{
SUBSTITUTIONS[ingredientFrom.name] = new Substitutes([ingredientFrom, ingredientTo]);
}
}
function setListSubstitute(name, subsList){
let ingredientList = [];
subsList.forEach(sub => {
var name = sub[0]
var unitParse = parseUnit(sub[1]);
ingredientList.push(new Ingredient(name, unitParse[0], unitParse[1]));
});
if(name in SUBSTITUTIONS){
SUBSTITUTIONS[name].addList(ingredientList);
}
else{
SUBSTITUTIONS[name] = new Substitutes(ingredientList);
}
}