physical-cpu-count is a lovely example of small packages on npm doing one thing well. It's a cross-platform solution with clearly discussed limitations and design decisions regarding hyperthreading. https://www.npmjs.com/package/physical-cpu-count