Skip to content

Instantly share code, notes, and snippets.

@Richienb
Created June 23, 2019 01:01
Show Gist options
  • Select an option

  • Save Richienb/0f92cfb54a1c2ed4d14c3196d83ca2a4 to your computer and use it in GitHub Desktop.

Select an option

Save Richienb/0f92cfb54a1c2ed4d14c3196d83ca2a4 to your computer and use it in GitHub Desktop.
Get core count
export var cores = (() => {
if (typeof process !== 'undefined' && process.release.name === 'node') {
return require('os').cpus().length;
} else if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency !== 'undefined') {
return navigator.hardwareConcurrency
} else if (typeof window !== 'undefined') {
console.log("Please use https://github.com/oftn-oswg/core-estimator")
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment