@vbarbarosh/node-helpers 3.38.0 → 3.38.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/package.json
CHANGED
package/src/format_kilo.js
CHANGED
|
@@ -11,7 +11,7 @@ function format_kilo(num)
|
|
|
11
11
|
return num.toString();
|
|
12
12
|
}
|
|
13
13
|
const i = parseInt(Math.floor(Math.log(num) / Math.log(1000)), 10);
|
|
14
|
-
return `${(num / (1000 ** i)).toFixed(2)}
|
|
14
|
+
return `${(num / (1000 ** i)).toFixed(2)}${sizes[i]}`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
module.exports = format_kilo;
|
package/src/format_kilo.test.js
CHANGED
|
@@ -4,10 +4,10 @@ const format_progress_kilo = require('./format_progress_kilo');
|
|
|
4
4
|
const items = [
|
|
5
5
|
['~', {percents: 0, total: 0, done: 0, rate: 0, eta: 0, duration: 0}],
|
|
6
6
|
['~ duration=00:00:01', {percents: 0, total: 0, done: 0, rate: 0, eta: 0, duration: 1}],
|
|
7
|
-
['25.25% |
|
|
8
|
-
['25.25% |
|
|
7
|
+
['25.25% | 5.00M of 15.00M at ~ ETA ~ duration=00:00:01', {percents: 0.2525, total: 15*1000*1000, done: 5*1000*1000, rate: 0, eta: 0, duration: 1}],
|
|
8
|
+
['25.25% | 5.00M of 15.00M at 10.00M/s ETA 00:00:05 duration=00:00:01', {percents: 0.2525, total: 15*1000*1000, done: 5*1000*1000, rate: 10*1000*1000, eta: 5, duration: 1}],
|
|
9
9
|
// edge case: done > total
|
|
10
|
-
['
|
|
10
|
+
['15.00M at 10.00M/s duration=00:00:01', {percents: 5.2525, total: 5*1000*1000, done: 15*1000*1000, rate: 10*1000*1000, eta: 5, duration: 1}],
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
describe('format_progress_kilo', function () {
|