Skip to content

Commit c89435e

Browse files
committed
fix food and add meal
1 parent 1b02c05 commit c89435e

File tree

6 files changed

+51
-1
lines changed

6 files changed

+51
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "carbon-footprint",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "Calculate your carbon footprint. Food, transport, purchases, fashion, electricity and digital activities like streaming.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import { getInternetUsageCarbonImpact } from './internet';
55
import { streaming, StreamingType } from './streaming';
66
import { purchase, PurchaseType } from './purchase';
77
import { fashion, FashionType } from './fashion';
8+
import { meal, MealType } from './meal';
89

910
export {
11+
meal,
12+
MealType,
1013
food,
1114
FoodType,
1215
transport,

src/meal/__tests__/meal.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { keys, map } from 'ramda';
2+
import { meal, MealType } from '../';
3+
4+
test('All meal keys should contain a valid number', () => {
5+
const foodKeys = keys(meal);
6+
map((item: number) => expect(typeof foodKeys[item]).toBe('number'));
7+
});
8+
9+
test('Number of default exports equals number of enums', () => {
10+
const enumsCount = Object.keys(MealType).length;
11+
const defaultExportsCount = Object.keys(meal).length;
12+
13+
expect(defaultExportsCount).toEqual(enumsCount);
14+
});

src/meal/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import meal from './meal';
2+
import { MealType } from './meal.enum';
3+
4+
export { meal, MealType };

src/meal/meal.enum.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export enum MealType {
2+
highMeat = 'highMeat',
3+
mediumMeat = 'mediumMeat',
4+
lowMeat = 'lowMeat',
5+
pescetarian = 'pescetarian',
6+
vegetarian = 'vegetarian',
7+
vegan = 'vegan',
8+
}

src/meal/meal.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Unit: kgCO2eq per meal */
2+
3+
/* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4372775/ */
4+
/* Mean greenhouse gas emissions per 2,000 kcal */
5+
/* https://globalnews.ca/news/3615212/this-is-what-your-breakfast-lunch-and-dinner-calories-actually-look-like/ */
6+
/* Human get around 600 calories per meal */
7+
const highMeat = (7.19 * 600) / 2000;
8+
const mediumMeat = (5.63 * 600) / 2000;
9+
const lowMeat = (4.67 * 600) / 2000;
10+
const pescetarian = (3.91 * 600) / 2000;
11+
const vegetarian = (3.81 * 600) / 2000;
12+
const vegan = (2.89 * 600) / 2000;
13+
14+
export default {
15+
highMeat,
16+
mediumMeat,
17+
lowMeat,
18+
pescetarian,
19+
vegetarian,
20+
vegan,
21+
};

0 commit comments

Comments
 (0)