Socket
Socket
Sign inDemoInstall

hardware-info

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

2

index.d.ts

@@ -1,2 +0,2 @@

export function getCpus(): {
export function getCpu(): {
total: number;

@@ -3,0 +3,0 @@ model: string;

@@ -5,5 +5,5 @@ import os from 'node:os';

export function getCpus() {
export function getCpu() {
return {
total: Number.parseInt(cpus.length, 10),
threads: Number.parseInt(cpus.length, 10),
model: `${cpus[0].model}`,

@@ -21,2 +21,30 @@ speed: Number.parseInt(cpus[0].speed, 10),

export function getOsArch() {
return {
arch: `${os.arch()}`,
};
}
export function getNetInterfaces() {
const interfaces = os.networkInterfaces();
const response = Object.keys(interfaces).map(element => {
if (Array.isArray(interfaces[element])) {
return {
name: element,
addresses: interfaces[element].map(_interface => ({
path: _interface.address,
internal: _interface.internal,
})),
};
}
return {
name: element,
addresses: interfaces[element].address,
};
});
return response;
}
function formatBytes(bytes) {

@@ -23,0 +51,0 @@ const units = ['bytes', 'KB', 'MB', 'GB', 'TB'];

{
"name": "hardware-info",
"version": "1.0.2",
"version": "1.0.3",
"description": "A lightweight way to get the hardware information.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,11 +10,17 @@ # hardware-info

```javascript
import {getCpus} from 'hardware-info';
import {getCpu, getRam, get} from 'hardware-info';
console.log(getCpus());
// => { total: 16, model: 'Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz', speed: 2904 }'
console.log(getCpu());
// => { threads: 16, model: 'Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz', speed: 2904 }'
console.log(getRam());
//=> '{ total: '15.93 GB', free: '7.15 GB' }'
console.log(getNetInterfaces());
//=> '[{"name":"Ethernet 7","addresses":[{"path":"fe80::81aa:d714:a0f:90cf","internal":false},{"path":"192.168.56.1","internal":false}]'
console.log(getOsArch());
//=> '{"arch":"x64"}'
```
## Unpacked Size
Less than 5 kB
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc