@putout/formatter-memory 3.0.1 → 3.1.0
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.
- package/lib/memory.js +16 -2
- package/package.json +5 -4
package/lib/memory.js
CHANGED
|
@@ -7,11 +7,16 @@ import once from 'once';
|
|
|
7
7
|
import format from 'format-io';
|
|
8
8
|
import montag from 'montag';
|
|
9
9
|
|
|
10
|
+
import {hrtime} from 'node:process';
|
|
11
|
+
|
|
12
|
+
const start = hrtime.bigint();
|
|
13
|
+
|
|
10
14
|
const OK = '👌';
|
|
11
15
|
const {
|
|
12
16
|
green,
|
|
13
17
|
yellow,
|
|
14
18
|
red,
|
|
19
|
+
blueBright,
|
|
15
20
|
} = chalk;
|
|
16
21
|
const formatErrorsCount = (a) => a ? red(a) : OK;
|
|
17
22
|
|
|
@@ -70,7 +75,7 @@ export default ({name, options, places, index, count, filesCount, errorsCount})
|
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
const getColorFn = (color) => {
|
|
73
|
-
if (
|
|
78
|
+
if (color.startsWith('#'))
|
|
74
79
|
return chalk.hex(color);
|
|
75
80
|
|
|
76
81
|
return chalk[color];
|
|
@@ -121,8 +126,17 @@ function getInfo(memory) {
|
|
|
121
126
|
return montag`
|
|
122
127
|
heap used: ${green(heapUsed)}
|
|
123
128
|
heap total: ${yellow(heapTotal)}
|
|
124
|
-
rss: ${red(rss)}
|
|
129
|
+
rss: ${red(rss)},
|
|
130
|
+
time: ${blueBright(calcTime())}
|
|
125
131
|
|
|
126
132
|
`;
|
|
127
133
|
}
|
|
128
134
|
|
|
135
|
+
function calcTime() {
|
|
136
|
+
const end = hrtime.bigint();
|
|
137
|
+
const time = Math.round(Number(end - start) / 1e9);
|
|
138
|
+
const minutes = Math.floor(time / 60);
|
|
139
|
+
const seconds = time % 60;
|
|
140
|
+
|
|
141
|
+
return `0${minutes}:${seconds <= 9 ? '0' : ''}${seconds}`;
|
|
142
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/formatter-memory",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "🐊Putout formatter shows memory usage",
|
|
6
6
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/formatter-memory#readme",
|
|
7
7
|
"main": "lib/memory.js",
|
|
8
|
+
"commitType": "colon",
|
|
8
9
|
"release": false,
|
|
9
10
|
"tag": false,
|
|
10
11
|
"changelog": false,
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
"@putout/test": "^5.0.0",
|
|
45
46
|
"c8": "^7.5.0",
|
|
46
47
|
"eslint": "^8.0.1",
|
|
47
|
-
"eslint-plugin-
|
|
48
|
-
"eslint-plugin-putout": "^
|
|
48
|
+
"eslint-plugin-n": "^15.2.4",
|
|
49
|
+
"eslint-plugin-putout": "^16.0.0",
|
|
49
50
|
"madrun": "^9.0.0",
|
|
50
51
|
"mock-require": "^3.0.3"
|
|
51
52
|
},
|