https://github.com/cnumr/ecoindex_js
EcoIndex computor
https://github.com/cnumr/ecoindex_js
Last synced: 4 months ago
JSON representation
EcoIndex computor
- Host: GitHub
- URL: https://github.com/cnumr/ecoindex_js
- Owner: cnumr
- License: other
- Created: 2022-12-14T08:36:47.000Z (over 3 years ago)
- Default Branch: 1.x
- Last Pushed: 2025-08-25T09:36:48.000Z (11 months ago)
- Last Synced: 2025-09-10T04:39:01.253Z (11 months ago)
- Language: JavaScript
- Size: 203 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EcoIndex - JS
This project provides methods for the EcoIndex calculation.
It is based on the work of the association [GreenIT](https://www.greenit.fr/)
and the web extension [GreenIT-Analysis](https://github.com/cnumr/GreenIT-Analysis/).
The sources are based on the initial Web Extension ([https://github.com/cnumr/GreenIT-Analysis/blob/master/script/ecoIndex.js](https://github.com/cnumr/GreenIT-Analysis/blob/master/script/ecoIndex.js)) code.
The calculation method is discribed on here : ([EcoIndex pouplation](https://www.ecoindex.fr/comment-ca-marche/))
# 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
```javascript
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
```javascript
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](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.