@putout/formatter-memory 3.0.1 → 3.1.1
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 +19 -2
- package/package.json +5 -4
package/lib/memory.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Writable} from 'stream';
|
|
2
|
+
import {hrtime} from 'process';
|
|
2
3
|
|
|
3
4
|
import dump from '@putout/formatter-dump';
|
|
4
5
|
import cliProgress from 'cli-progress';
|
|
@@ -7,11 +8,15 @@ import once from 'once';
|
|
|
7
8
|
import format from 'format-io';
|
|
8
9
|
import montag from 'montag';
|
|
9
10
|
|
|
11
|
+
const start = once(() => hrtime.bigint());
|
|
12
|
+
const end = once(() => 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
|
|
|
@@ -22,6 +27,8 @@ const {
|
|
|
22
27
|
} = process.env;
|
|
23
28
|
|
|
24
29
|
export default ({name, options, places, index, count, filesCount, errorsCount}) => {
|
|
30
|
+
start();
|
|
31
|
+
|
|
25
32
|
const {
|
|
26
33
|
color = '#ea4336',
|
|
27
34
|
minCount = 0,
|
|
@@ -70,7 +77,7 @@ export default ({name, options, places, index, count, filesCount, errorsCount})
|
|
|
70
77
|
};
|
|
71
78
|
|
|
72
79
|
const getColorFn = (color) => {
|
|
73
|
-
if (
|
|
80
|
+
if (color.startsWith('#'))
|
|
74
81
|
return chalk.hex(color);
|
|
75
82
|
|
|
76
83
|
return chalk[color];
|
|
@@ -121,8 +128,18 @@ function getInfo(memory) {
|
|
|
121
128
|
return montag`
|
|
122
129
|
heap used: ${green(heapUsed)}
|
|
123
130
|
heap total: ${yellow(heapTotal)}
|
|
124
|
-
rss: ${red(rss)}
|
|
131
|
+
rss: ${red(rss)},
|
|
132
|
+
time: ${blueBright(calcTime())}
|
|
125
133
|
|
|
126
134
|
`;
|
|
127
135
|
}
|
|
128
136
|
|
|
137
|
+
export const maybeZero = (a) => a <= 9 ? '0' : '';
|
|
138
|
+
|
|
139
|
+
function calcTime() {
|
|
140
|
+
const time = Math.round(Number(end() - start()) / 1e9);
|
|
141
|
+
const minutes = Math.floor(time / 60);
|
|
142
|
+
const seconds = time % 60;
|
|
143
|
+
|
|
144
|
+
return `${maybeZero(minutes)}${minutes}:${maybeZero(seconds)}${seconds}`;
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/formatter-memory",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
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
|
},
|