forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.js
50 lines (46 loc) · 2.18 KB
/
data.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
41
42
43
44
45
46
47
48
49
50
const data = [
{
name: 'Tacos',
description: 'A taco (/ˈtækoʊ/ or /ˈtɑːkoʊ/) is a traditional Mexican dish composed of a corn or wheat tortilla folded or rolled around a filling. A taco can be made with a variety of fillings, including beef, pork, chicken, seafood, vegetables and cheese, allowing for great versatility and variety. A taco is generally eaten without utensils and is often accompanied by garnishes such as salsa, avocado or guacamole, cilantro (coriander), tomatoes, minced meat, onions and lettuce.',
items: [
{ name: 'Carne Asada', price: 7 },
{ name: 'Pollo', price: 6 },
{ name: 'Carnitas', price: 6 }
]
},
{
name: 'Burgers',
description: 'A hamburger (also called a beef burger, hamburger sandwich, burger or hamburg) is a sandwich consisting of one or more cooked patties of ground meat, usually beef, placed inside a sliced bun. Hamburgers are often served with lettuce, bacon, tomato, onion, pickles, cheese and condiments such as mustard, mayonnaise, ketchup, relish, and green chile.',
items: [
{ name: 'Buffalo Bleu', price: 8 },
{ name: 'Bacon', price: 8 },
{ name: 'Mushroom and Swiss', price: 6 }
]
},
{
name: 'Drinks',
description: 'Drinks, or beverages, are liquids intended for human consumption. In addition to basic needs, beverages form part of the culture of human society. Although all beverages, including juice, soft drinks, and carbonated drinks, have some form of water in them, water itself is often not classified as a beverage, and the word beverage has been recurrently defined as not referring to water.',
items: [
{ name: 'Lemonade', price: 3 },
{ name: 'Root Beer', price: 4 },
{ name: 'Iron Port', price: 5 }
]
}
]
const dataMap = data.reduce(function (map, category) {
category.itemsMap = category.items.reduce(function (itemsMap, item) {
itemsMap[item.name] = item
return itemsMap
}, {})
map[category.name] = category
return map
}, {})
exports.getAll = function () {
return data
}
exports.lookupCategory = function (name) {
return dataMap[name]
}
exports.lookupItem = function (category, item) {
return dataMap[category].itemsMap[item]
}