thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
389 stars 49 forks source link

export classes inside of the CO2 class #220

Closed fershad closed 1 month ago

fershad commented 2 months ago

Triage

Type of change

Please select any of the below items that are appropriate.

This pull request:

Related issue/s

Please list below any issues this pull request is related to.

Docs changes required

Do any changes made in this pull request require parts of the CO2.js documentation to be updated?

It has been decided that at this time, this change will not be documented.

If you answered "Yes", please create an corresponding issue in our Developer Documentation repository.

Describe the changes made in this pull request

As clearly as possible, describe the changes made in the pull request. You should at least detail "what changes have been made" and "what the results of these changes will be".

This change exposes all private functions and variables that are available in the OneByte and Sustainable Web Design Model classes that are used in CO2.js. The change would allow developers to access energy estimation functions, embodied and operational emissions estimation functions, and other constants that are included in those classes.

As a result of this change, developers can access these functions as below:

import {co2} from "@tgwf/co2";
let swdmv3 =  new co2().SustainableWebDesignV3();

// Access the Sustainable Web Design Model directly.
const operationalEnergy = swdmv3.operationalEnergyPerSegment(1000);
console.log(operationalEnergy);

// Access the Sustainable Web Design Model via CO2.js API (perByte/perVisit functions)
const emissions = new co2();
const estimate = emissions.perByte(1000)
fershad commented 1 month ago

@mrchrisadams I feel that this PR is ready for a brief review.

mrchrisadams commented 1 month ago

Hi Fish! This looks good, thanks! Merge away :)