-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parseOptions validates args it is not supposed to get for perByte(Trace) functions #224
Comments
Hi Alex. Can you please give a code example using both |
Hi fershad, of course, at least for
where
I simplified |
Cheers Alex. Yep, I can see that now for import { co2 } from '@tgwf/co2'
const estimate = new co2({ model: "swd", version: 4 })
const bytesSent = 1000 * 1000 * 1000; // 1GB expressed in bytes
const options = {
greenHostingFactor: 0,
gridIntensities: {
device: 450,
dataCenter: 209,
}
};
const estimatedCO2 = estimate.perByteTrace(bytesSent, undefined, options);
console.log(estimatedCO2); Running the code below sees the following console output: The dataReloadRatio option must be a number. You passed in a undefined.
Falling back to default value.
The firstVisitPercentage option must be a number. You passed in a undefined.
Falling back to default value.
The returnVisitPercentage option must be a number. You passed in a undefined.
Falling back to default value.
{
co2: 148.2,
green: false,
variables: {
description: 'Below are the variables used to calculate this CO2 estimate.',
bytes: 1000000000,
gridIntensity: {
description: 'The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.',
device: [Object],
dataCenter: [Object],
network: [Object]
},
greenHostingFactor: 0
}
} Those first three lines are the superfluous warning messages that are being returned, despite being not relevant to the |
Yes, that's it. Thank you for looking into it :) |
@alexzurbonsen I won't be able to take a proper look at this until early October. If you've got time and capacity between now & then, we'd welcome a PR which I could review when I'm back from leave. |
Describe the bug
When you call
perByte
orperByteTrace
the functionparseOptions
also validates args that it cannot get (dataReloadRatio
) It logs a lot of stuff which can be consufing in the logs since you get messages that do not apply.Also I am not sure it needs logging at all. After all the values are optional in to begin with.<-- this does not happen for perByteTrace options.To Reproduce
Steps to reproduce the behavior:
Call
perByte
and observe console.logs.Expected behavior
No misleading logs or in this case even better: no logs at all.
The text was updated successfully, but these errors were encountered: