Skip to content

Commit

Permalink
tiny fixes (let.., use strict, merge)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Aug 23, 2016
1 parent 6c5fcb9 commit f8eb89e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ npm install mmon -g
$ mmon
```

Press `q` (quit) or `CTRL-C` to exit mmon.
Press `q` (quit) or `CTRL-c` to exit mmon.

## Features

Expand Down Expand Up @@ -53,6 +53,7 @@ mmon -i 5

| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 1.0.4 | 2016-08-23 | tiny fixes (merge, use strict) |
| 1.0.3 | 2016-08-19 | tiny improvement, updated copyright notes |
| 1.0.2 | 2016-08-19 | tiny fixes |
| 1.0.1 | 2016-08-19 | documentation update, colors |
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function displayAll(first) {

lines[0] = lines[0] + cols.log('MISC: ', 'white', 'darkgray');
lines[1] = lines[1] + 'Internet Latency : ' + (dynamicData.inetLatency >= 0 ? draw.fmtNum(dynamicData.inetLatency, 2, 8, 2000, 5000) + ' ms' : ' - ');
lines[2] = lines[2] + 'Battery Level : ' + (dynamicData.battery.hasbattery ? draw.fmtNum(dynamicData.battery.percent, 1, 5) + '%' + (dynamicData.battery.ischarging ? ' !!' : ' ') : ' ---- ');
lines[2] = lines[2] + 'Battery Level : ' + (dynamicData.battery.hasbattery ? draw.fmtNum(dynamicData.battery.percent, 1, 5) + '%' + (dynamicData.battery.ischarging ? cols.log(' ++','green') : ' ') : ' ---- ');

console.log();
lines.forEach(line => {
Expand Down
7 changes: 4 additions & 3 deletions lib/args.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

// ==================================================================================
// args.js
// ----------------------------------------------------------------------------------
Expand All @@ -21,10 +22,10 @@ function getArgs() {
return !isNaN(parseFloat(n)) && isFinite(n);
}

var args = process.argv.slice(2);
let args = process.argv.slice(2);

var result = {};
var current = 0;
let result = {};
let current = 0;
args.forEach(function (val, index) {
if (index == current) {
current = index + 1;
Expand Down
30 changes: 21 additions & 9 deletions lib/cols.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
'use strict';

// inspired by: https://github.com/jbnicolai/ansi-256-colors
// ==================================================================================
// draw.js
// ----------------------------------------------------------------------------------
// Description: tiny CLI draw library
// for Node.js
// Copyright: (c) 2016
// Author: Sebastian Hildebrandt
// ----------------------------------------------------------------------------------
// inspired by: https://github.com/jbnicolai/ansi-256-colors
// Contributors: -
// ----------------------------------------------------------------------------------
// License: MIT
// ==================================================================================

var fgcodes = Array.apply(null, new Array(256)).map(function (_, i) { return '\x1b[38;5;' + i + 'm'; });
var fg_rgb = fgcodes.slice(16, 232);
var fg_gray = fgcodes.slice(232, 256);
let fgcodes = Array.apply(null, new Array(256)).map(function (_, i) { return '\x1b[38;5;' + i + 'm'; });
let fg_rgb = fgcodes.slice(16, 232);
let fg_gray = fgcodes.slice(232, 256);

var bgcodes = Array.apply(null, new Array(256)).map(function (_, i) { return '\x1b[48;5;' + i + 'm'; });
var bg_rgb = bgcodes.slice(16, 232);
var bg_gray = bgcodes.slice(232, 256);
var reset_str = '\x1b[0m';
let bgcodes = Array.apply(null, new Array(256)).map(function (_, i) { return '\x1b[48;5;' + i + 'm'; });
let bg_rgb = bgcodes.slice(16, 232);
let bg_gray = bgcodes.slice(232, 256);
let reset_str = '\x1b[0m';

var colors = {
let colors = {
black: 0,
red: 1,
green: 41,
Expand Down
1 change: 1 addition & 0 deletions lib/draw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

// ==================================================================================
// draw.js
// ----------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions lib/libObj.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use strict';

function merge(obj1, obj2) {

for (var p in obj2) {
for (let p in obj2) {
if (obj2.hasOwnProperty(p)) {
try {
// Property in destination object set; update its value.
if ( obj2[p].constructor==Object ) {
obj1[p] = MergeRecursive(obj1[p], obj2[p]);
obj1[p] = merge(obj1[p], obj2[p]);
} else {
obj1[p] = obj2[p];
}
Expand Down
2 changes: 2 additions & 0 deletions lib/libTime.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

function getTimeAgo(val) {
let diff = new Date().getTime() - new Date(val).getTime();

Expand Down

0 comments on commit f8eb89e

Please sign in to comment.