-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: expose cpu info #6
Conversation
src/cpu-info.ts
Outdated
* | ||
* @returns The number of logical CPU cores, or undefined if not available. | ||
*/ | ||
static getNumLogicalCores(): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the JSDoc says this method could return "undefined if not available" but here we say it always returns a number. Checking the MDN docs it does seem like all major browsers support it, though I suppose it is possible that someone might use an unsupported browser.
Should we set the return type to number | undefined
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option could be using something like:
static isCapableOfSending1080pVideo(): CapabilityState {
const numCores = CpuInfo.getNumLogicalCores();
if (numCores === undefined) {
return CapabilityState.UNKNOWN;
}
if (numCores < 2) {
return CapabilityState.NOT_CAPABLE;
}
return CapabilityState.CAPABLE;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for making the changes. I think once we add more methods to CpuInfo
it will become even more obvious the benefits of making it its own class.
One last thing before I approve: could we update the README with an example using the new CpuInfo
API (similar to BrowserInfo
)?
# [1.3.0](v1.2.0...v1.3.0) (2024-05-23) ### Features * expose cpu info ([#6](#6)) ([6e43d38](6e43d38))
Description
This PR introduces a new feature to expose the
CpuInfo
private property to show the number of CPU cores available on a system.JIRA Ticket
WEBEX-379500
Changes
getCpuInfo()