Skip to content

Commit

Permalink
add fashion as type
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBresson committed Apr 14, 2021
1 parent afe7af0 commit 3c72cbd
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 31 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Carbon Footprint Diagnostic 👣🩺

# Carbon Footprint Diagnostic 🏭👣🩺

![](https://github.com/NMF-earth/nmf-app/workflows/Test%20CI/badge.svg)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](code_of_conduct.md)
[![Build Status](https://img.shields.io/static/v1.svg?label=CSL&message=software%20against%20climate%20change&color=green?style=flat&logo=github)](https://github.com/climate-strike/license)

Calculate your carbon footprint. Food, transport, purchases, electricity and digital activities like streaming.
Calculate your carbon footprint. Food, transport, purchases, fashion, electricity and digital activities like streaming.

Used in [NMF.earth](https://nmf.earth/) open-source project.
Can be found on [NPM](https://www.npmjs.com/package/carbon-footprint).
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "carbon-footprint",
"version": "1.4.2",
"description": "Calculate your carbon footprint. Food, transport, purchases, electricity and digital activities like streaming.",
"version": "1.5.0",
"description": "Calculate your carbon footprint. Food, transport, purchases, fashion, electricity and digital activities like streaming.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
Expand Down Expand Up @@ -29,7 +29,8 @@
"purchases",
"digital",
"streaming",
"electricity"
"electricity",
"fashion"
],
"author": "NMF.earth <[email protected]> (http://nmf.earth)",
"license": "GPLv3",
Expand Down
15 changes: 15 additions & 0 deletions src/fashion/__tests__/fashion.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { keys, map } from 'ramda';
import fashion from '../fashion';
import { FashionType } from '../fashion.enum';

test('All fashion keys should contain a valid number', () => {
const purchaseKeys = keys(fashion);
map((item: number) => expect(typeof purchaseKeys[item]).toBe('number'));
});

test('Number of default exports equals number of enums', () => {
const enumsCount = Object.keys(FashionType).length;
const defaultExportsCount = Object.keys(fashion).length;

expect(defaultExportsCount).toEqual(enumsCount);
});
9 changes: 9 additions & 0 deletions src/fashion/fashion.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export enum FashionType {
shirt = 'shirt',
tshirt = 'tshirt',
jeans = 'jeans',
sweater = 'sweater',
coat = 'coat',
dress = 'dress',
shoes = 'shoes',
}
22 changes: 22 additions & 0 deletions src/fashion/fashion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Unit: kgCO2eq per product */

/* Clothing
https://www.ademe.fr/sites/default/files/assets/documents/poids_carbone-biens-equipement-201809-rapport.pdf
*/
const shirt = (13 + 12) / 2;
const tshirt = (7 + 10 + 6) / 3;
const jeans = 25;
const sweater = (28 + 26 + 31 + 56 + 12) / 5;
const coat = (89 + 39 + 25) / 3;
const dress = (56 + 56 + 51) / 3;
const shoes = (15 + 19 + 20) / 3;

export default {
shirt,
tshirt,
jeans,
sweater,
coat,
dress,
shoes,
};
4 changes: 4 additions & 0 deletions src/fashion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import fashion from './fashion';
import { FashionType } from './fashion.enum';

export { fashion, FashionType };
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { electricity, ElectricityType } from './electricity';
import { getInternetUsageCarbonImpact } from './internet';
import { streaming, StreamingType } from './streaming';
import { purchase, PurchaseType } from './purchase';
import { fashion, FashionType } from './fashion';

export {
food,
Expand All @@ -17,4 +18,6 @@ export {
StreamingType,
purchase,
PurchaseType,
fashion,
FashionType,
};
7 changes: 0 additions & 7 deletions src/purchase/purchase.enum.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
export enum PurchaseType {
shirt = 'shirt',
tshirt = 'tshirt',
jeans = 'jeans',
sweater = 'sweater',
coat = 'coat',
dress = 'dress',
shoes = 'shoes',
smartphone = 'smartphone',
tablet = 'tablet',
computer = 'computer',
Expand Down
18 changes: 0 additions & 18 deletions src/purchase/purchase.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
/* Unit: kgCO2eq per product */

/* Clothing
https://www.ademe.fr/sites/default/files/assets/documents/poids_carbone-biens-equipement-201809-rapport.pdf
*/
const shirt = (13 + 12) / 2;
const tshirt = (7 + 10 + 6) / 3;
const jeans = 25;
const sweater = (28 + 26 + 31 + 56 + 12) / 5;
const coat = (89 + 39 + 25) / 3;
const dress = (56 + 56 + 51) / 3;
const shoes = (15 + 19 + 20) / 3;

/* Tech
Reasons to choose Apple :
- world leader
Expand Down Expand Up @@ -41,13 +30,6 @@ const hybridCar = 6500;
const eletricCar = 8800;

export default {
shirt,
tshirt,
jeans,
sweater,
coat,
dress,
shoes,
smartphone,
tablet,
computer,
Expand Down

0 comments on commit 3c72cbd

Please sign in to comment.