Skip to content

Commit df2b0e6

Browse files
committed
add enum
1 parent 2caa8be commit df2b0e6

8 files changed

Lines changed: 61 additions & 6 deletions

File tree

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.0.5",
3+
"version": "1.0.6",
44
"description": "Calculate your carbon footprint. Food, transport and purchases.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/food/food.enum.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export enum FoodEnum {
2+
redMeat = 'redMeat',
3+
whiteMeat = 'whiteMeat',
4+
fish = 'fish',
5+
lamb = 'lamb',
6+
beef = 'beef',
7+
cheese = 'cheese',
8+
pork = 'pork',
9+
turkey = 'turkey',
10+
chicken = 'chicken',
11+
tuna = 'tuna',
12+
eggs = 'eggs',
13+
potatoes = 'potatoes',
14+
rice = 'rice',
15+
nuts = 'nuts',
16+
beans = 'beans',
17+
tofu = 'tofu',
18+
vegetables = 'vegetables',
19+
milk = 'milk',
20+
fruit = 'fruit',
21+
lentils = 'lentils',
22+
}

src/food/food.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
const lamb = 39.2;
66
const beef = 27.0;
7+
const readMeat = (lamb + beef) / 2;
78
const cheese = 13.5;
89
const pork = 12.1;
910
const turkey = 10.9;
1011
const chicken = 6.9;
12+
const whiteMeat = (pork + turkey + chicken) / 3;
1113
const tuna = 6.1;
14+
const fish = tuna;
1215
const eggs = 4.8;
1316
const potatoes = 2.9;
1417
const rice = 2.7;
@@ -21,6 +24,9 @@ const fruit = 1.1;
2124
const lentils = 0.9;
2225

2326
export default {
27+
readMeat,
28+
whiteMeat,
29+
fish,
2430
lamb,
2531
beef,
2632
cheese,

src/food/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export { default } from './food';
1+
import food from './food';
2+
import { FoodEnum } from './food.enum';
3+
4+
export { food, FoodEnum };

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import transport from './transport';
2-
import food from './food';
1+
import { food, FoodEnum } from './food';
2+
import { transport, TransportEnum } from './transport';
33
import version from './version';
44

5-
export { transport, food, version };
5+
export { food, FoodEnum, transport, TransportEnum, version };

src/transport/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export { default } from './transport';
1+
import transport from './transport';
2+
import { TransportEnum } from './transport.enum';
3+
4+
export { transport, TransportEnum };

src/transport/transport.enum.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export enum TransportEnum {
2+
plane = 'plane',
3+
bus = 'bus',
4+
boat = 'boat',
5+
car = 'car',
6+
fossilFueledCar = 'fossilFueledCar',
7+
electricVehicle = 'electricVehicle',
8+
hybridCar = 'hybridCar',
9+
carSharing = 'carSharing',
10+
motorbike = 'motorbike',
11+
shortDistanceBus = 'shortDistanceBus',
12+
longDistanceBus = 'longDistanceBus',
13+
train = 'train',
14+
shortHaulFlight = 'shortHaulFlight',
15+
mediumHaulFlight = 'mediumHaulFlight',
16+
longHaulFlight = 'longHaulFlight',
17+
}

src/transport/transport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const fossilFueledCar = 0.000257;
66
const electricVehicle = 0.000081;
7+
const car = fossilFueledCar;
78
const hybridCar = 0.00018;
89
const carSharing = 0.000147;
910
const motorbike = 0.000108;
@@ -14,8 +15,11 @@ const boat = 0.000803;
1415
const shortHaulFlight = 0.00034;
1516
const mediumHaulFlight = 0.000286;
1617
const longHaulFlight = 0.000239;
18+
const plane = (shortHaulFlight + mediumHaulFlight + longHaulFlight) / 3;
1719

1820
export default {
21+
plane,
22+
car,
1923
fossilFueledCar,
2024
electricVehicle,
2125
hybridCar,

0 commit comments

Comments
 (0)