diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ed618..f18b410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.27.2 | 2020-08-26 | fixed issue breaking node v4 compatibility | | 4.27.1 | 2020-08-25 | `networkStats()` fixed packages dropped (linux) | | 4.27.0 | 2020-08-24 | `observe()` added function to observe/watch system parameters | | 4.26.12 | 2020-08-21 | `versions()` fixed issue windows | diff --git a/README.md b/README.md index 77069ee..76e0283 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Lightweight collection of 40+ functions to retrieve detailed hardware, system an - supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support - no npm dependencies (for production) -**Attention**: this is a `node.js` library. It is supposed to be used as a backend/server-side library and will definilely not work within a browser. +**Attention**: this is a `node.js` library. It is supposed to be used as a backend/server-side library and will definilely not work within a browser. ### Installation @@ -75,11 +75,11 @@ const si = require('systeminformation'); // promises style - new since version 3 si.cpu() - .then(data => console.log(data)) - .catch(error => console.error(error)); + .then(data => console.log(data)) + .catch(error => console.error(error)); ``` -**Callback, Promises, Awync Await** +**Callback, Promises, Awync / Await** ## News and Changes @@ -106,7 +106,7 @@ I was able to test it on several Debian, Raspbian, Ubuntu distributions as well If you have comments, suggestions & reports, please feel free to contact me! -I also created a nice little command line tool called [mmon][mmon-github-url] (micro-monitor) for Linux and macOS, also available via [github][mmon-github-url] and [npm][mmon-npm-url] +I also created a nice little command line tool called [mmon][mmon-github-url] (micro-monitor) for Linux and macOS, also available via [github][mmon-github-url] and [npm][mmon-npm-url] ## Reference @@ -653,13 +653,13 @@ Remember: all functions (except `version` and `time`) are implemented as asynchr const si = require('systeminformation'); si.cpu(function(data) { - console.log('CPU Information:'); - console.log('- manufucturer: ' + data.manufacturer); - console.log('- brand: ' + data.brand); - console.log('- speed: ' + data.speed); - console.log('- cores: ' + data.cores); - console.log('- physical cores: ' + data.physicalCores); - console.log('...'); + console.log('CPU Information:'); + console.log('- manufucturer: ' + data.manufacturer); + console.log('- brand: ' + data.brand); + console.log('- speed: ' + data.speed); + console.log('- cores: ' + data.cores); + console.log('- physical cores: ' + data.physicalCores); + console.log('...'); }) ``` @@ -673,16 +673,16 @@ When omitting callback parameter (cb), then you can use all function in a promis const si = require('systeminformation'); si.cpu() - .then(data => { - console.log('CPU Information:'); - console.log('- manufucturer: ' + data.manufacturer); - console.log('- brand: ' + data.brand); - console.log('- speed: ' + data.speed); - console.log('- cores: ' + data.cores); - console.log('- physical cores: ' + data.physicalCores); - console.log('...'); - }) - .catch(error => console.error(error)); + .then(data => { + console.log('CPU Information:'); + console.log('- manufucturer: ' + data.manufacturer); + console.log('- brand: ' + data.brand); + console.log('- speed: ' + data.speed); + console.log('- cores: ' + data.cores); + console.log('- physical cores: ' + data.physicalCores); + console.log('...'); + }) + .catch(error => console.error(error)); ``` ### Async / Await @@ -695,18 +695,18 @@ Since node v7.6 you can also use the `async` / `await` pattern. The above exampl const si = require('systeminformation'); async function cpuData() { - try { - const data = await si.cpu(); - console.log('CPU Information:'); - console.log('- manufucturer: ' + data.manufacturer); - console.log('- brand: ' + data.brand); - console.log('- speed: ' + data.speed); - console.log('- cores: ' + data.cores); - console.log('- physical cores: ' + data.physicalCores); - console.log('...'); - } catch (e) { - console.log(e) - } + try { + const data = await si.cpu(); + console.log('CPU Information:'); + console.log('- manufucturer: ' + data.manufacturer); + console.log('- brand: ' + data.brand); + console.log('- speed: ' + data.speed); + console.log('- cores: ' + data.cores); + console.log('- physical cores: ' + data.physicalCores); + console.log('...'); + } catch (e) { + console.log(e) + } } ``` @@ -715,7 +715,7 @@ async function cpuData() { #### macOS - Temperature Sensor To be able to measure temperature on macOS I created a little additional package. Due to some difficulties -in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms. +in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default, you will not get correct values. But if you need to detect macOS temperature just run the following additional @@ -741,7 +741,7 @@ e.g. on DEBIAN based systems by running `sudo apt-get install lm-sensors` #### Linux S.M.A.R.T. Status -To be able to detect S.M.A.R.T. status on Linux you need to install `smartmontools`. On DEBIAN based linux distributions you can install it by running `sudo apt-get install smartmontools` +To be able to detect S.M.A.R.T. status on Linux you need to install `smartmontools`. On DEBIAN based linux distributions you can install it by running `sudo apt-get install smartmontools` ## *: Additional Notes @@ -757,9 +757,9 @@ So basically, if you e.g. need a values for network stats every second, your cod const si = require('systeminformation'); setInterval(function() { - si.networkStats().then(data => { - console.log(data); - }) + si.networkStats().then(data => { + console.log(data); + }) }, 1000) ``` diff --git a/docs/history.html b/docs/history.html index 74ad317..4160ffe 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.27.2 + 2020-08-26 + fixed issue breaking node v4 compatibility + 4.27.1 2020-08-25 diff --git a/docs/index.html b/docs/index.html index ade78cf..40db54b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.27.1
+
Current Version: 4.27.2
@@ -207,7 +207,7 @@
Downloads last month
-
333
+
335
Dependends
diff --git a/lib/index.js b/lib/index.js index 4d7aee4..2b3a2a6 100755 --- a/lib/index.js +++ b/lib/index.js @@ -355,10 +355,10 @@ function observe(valueObject, interval, callback) { const result = setInterval(() => { get(valueObject).then(data => { if (JSON.stringify(_data) !== JSON.stringify(data)) { - _data = { ...data }; + _data = Object.assign({}, data ); callback(data); } - }) + }); }, interval); return result; }