Skip to content

cnumr/ecoindex_js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EcoIndex - JS

This project provides methods for the EcoIndex calculation.

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)

Install

Install package with npm
npm install ecoindex

How to use ?

computeEcoIndex(dom, req, size)

computeEcoIndex returns the ecoIndex according to 3 parameters.

Parameters

Name Type Description
dom number Number of DOM elements
req number Number of requests
size number Size 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

Name Type Description
ecoIndex number The 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

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.

About

EcoIndex computor

Resources

License

Stars

Watchers

Forks

Packages

No packages published