@e-mc/module 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +25 -27
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -558,7 +558,7 @@ class Module extends EventEmitter {
558
558
  this[_f] = new AbortController();
559
559
  this[_g] = null;
560
560
  }
561
- static get VERSION() { return "0.5.1" /* INTERNAL.VERSION */; }
561
+ static get VERSION() { return "0.5.3" /* INTERNAL.VERSION */; }
562
562
  static get LOG_TYPE() { return types_1.LOG_TYPE; }
563
563
  static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
564
564
  static get MAX_TIMEOUT() { return 2147483647; }
@@ -1620,34 +1620,32 @@ class Module extends EventEmitter {
1620
1620
  let result = '';
1621
1621
  if (cpu || all) {
1622
1622
  let usage = this.getCpuUsage(start, !cpu_bar);
1623
- if (usage) {
1624
- if (typeof usage === 'number') {
1625
- if (!cpu_single_core) {
1626
- usage /= CPU_CORETOTAL;
1627
- }
1628
- if (usage + 0.005 /* CPU_MEM.BAR_100_OFFSET */ >= 1) {
1629
- usage = 1;
1630
- }
1631
- let bar = 20 /* CPU_MEM.BAR_LENGTH */, red = 0.9 /* CPU_MEM.BAR_RED */, yellow = 0.75 /* CPU_MEM.BAR_YELLOW */;
1632
- if (typeof cpu_bar === 'number') {
1633
- bar = cpu_bar;
1634
- }
1635
- else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10 /* CPU_MEM.BAR_MIN_LENGTH */) {
1636
- let r, y;
1637
- [bar, r = 0.9 /* CPU_MEM.BAR_RED */, y = 0.75 /* CPU_MEM.BAR_YELLOW */] = cpu_bar;
1638
- if (r > 0 && r < 1 && y > 0 && y < 1 && y < r) {
1639
- red = r;
1640
- yellow = y;
1641
- }
1642
- }
1643
- const unit = Math.max(bar, 10 /* CPU_MEM.BAR_MIN_LENGTH */);
1644
- const length = Math.floor(usage * unit);
1645
- const hint = usage === 1 ? "MAX" /* CPU_MEM.BAR_100 */ : formatPercent(usage, 2);
1646
- result += chalk[usage >= red ? 'bgRed' : usage >= yellow ? 'bgYellow' : 'bgBlue'].white(':'.repeat(length)) + chalk.bgGrey.white(':'.repeat(unit - length)) + (hint ? chalk.bgWhite.grey(` ${hint} `) : '');
1623
+ if (typeof usage === 'number') {
1624
+ if (!cpu_single_core) {
1625
+ usage /= CPU_CORETOTAL;
1647
1626
  }
1648
- else {
1649
- result += usage + ' CPU' + (!cpu_single_core ? '/' + CPU_CORETOTAL : '');
1627
+ if (usage + 0.005 /* CPU_MEM.BAR_100_OFFSET */ >= 1) {
1628
+ usage = 1;
1650
1629
  }
1630
+ let bar = 20 /* CPU_MEM.BAR_LENGTH */, red = 0.9 /* CPU_MEM.BAR_RED */, yellow = 0.75 /* CPU_MEM.BAR_YELLOW */;
1631
+ if (typeof cpu_bar === 'number') {
1632
+ bar = cpu_bar;
1633
+ }
1634
+ else if (Array.isArray(cpu_bar) && cpu_bar[0] >= 10 /* CPU_MEM.BAR_MIN_LENGTH */) {
1635
+ let r, y;
1636
+ [bar, r = 0.9 /* CPU_MEM.BAR_RED */, y = 0.75 /* CPU_MEM.BAR_YELLOW */] = cpu_bar;
1637
+ if (r > 0 && r < 1 && y > 0 && y < 1 && y < r) {
1638
+ red = r;
1639
+ yellow = y;
1640
+ }
1641
+ }
1642
+ const unit = Math.max(bar, 10 /* CPU_MEM.BAR_MIN_LENGTH */);
1643
+ const length = Math.floor(usage * unit);
1644
+ const hint = usage === 1 ? "MAX" /* CPU_MEM.BAR_100 */ : usage < 0 ? "N/A" /* CPU_MEM.BAR_UNDER */ : formatPercent(usage, 2);
1645
+ result += chalk[usage >= red ? 'bgRed' : usage >= yellow ? 'bgYellow' : 'bgBlue'].white(':'.repeat(length)) + chalk.bgGrey.white(':'.repeat(unit - length)) + (hint ? chalk.bgWhite.grey(` ${hint} `) : '');
1646
+ }
1647
+ else if (usage) {
1648
+ result += usage + ' CPU' + (!cpu_single_core ? '/' + CPU_CORETOTAL : '');
1651
1649
  }
1652
1650
  }
1653
1651
  if (mem || all) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.5.1",
23
+ "@e-mc/types": "0.5.3",
24
24
  "abort-controller": "^3.0.0",
25
25
  "chalk": "4.1.2",
26
26
  "event-target-shim": "^5.0.1",