thegreenwebfoundation / co2.js

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

adds support for verbose response when checking domains #192

Closed sfishel18 closed 5 months ago

sfishel18 commented 7 months ago

Fixes #189

sfishel18 commented 7 months ago

@fershad / @mrchrisadams here's my initial implementation, let me if this looks like a good direction and if so i'll polish it up and add more test cases

sfishel18 commented 6 months ago

@fershad i think this is ready for an initial look from you. i plan to add additional tests for the new code paths, but want to make sure i'm on the right track.

a couple of specific things i wanted your feedback on:

  1. if i understood your comments on the issue, a goal of this is to make the function signatures for the two check functions consistent. i think it's possible to do that without breaking backwards compatibility, by doing introspection of the argument types. but the "overloaded" function signature is a little confusing, so i'd understand if you'd prefer to just go ahead and make a breaking change to the API.

  2. from what i can tell, the local database only contains a list of string domain names, so it doesn't have enough information to return verbose responses. i put in logic to throw an exception if a local database is used in combination with the verbose flag set.