1.0.5 • Published 11 months ago

ecoindex v1.0.5

Weekly downloads
-
License
CC-BY-NC-ND-3.0
Repository
github
Last release
11 months ago

EcoIndex - JS

This project provides methods for the EcoIndex population.

It is based on the work of the association GreenIT and the web extension GreenIT-Analysis.

The sources are based on the initial Web Extension (https://github.com/cnumr/GreenIT-Analysis/blob/master/script/ecoIndex.js) code. The calculation method is discribed on here : (EcoIndex pouplation)

How to use ?

computeEcoIndex(dom, req, size)

computeEcoIndex returns the ecoIndex according to 3 parameters.

Parameters

NameTypeDescription
domnumberNumber of DOM elements
reqnumberNumber of requests
sizenumberSize of response (Ko)

Example

import {computeEcoIndex} from "ecoindex";

const ecoIndex = computeEcoIndex(dom, req, size);

getEcoIndexGrade(ecoIndex)

getEcoIndexGrade returns the grade according to the ecoIndex value.

Parameters

NameTypeDescription
ecoIndexnumberThe EcoIndex value

Example

import {computeEcoIndex, getEcoIndexGrade} from "ecoindex";

const ecoIndex = computeEcoIndex(dom, req, size);
const grade = getEcoIndexGrade(ecoIndex);

Testing

We use mocha for testing. You can launch tests using this command :

npm test

License

Disclaimer

The LCA values used by ecoindex to evaluate environmental impacts are not under free license - ©Frédéric Bordage
Please also refer to the mentions provided in the code files for specifics on the IP regime.