Skip to content

Commit c65a1bb

Browse files
authoredJun 6, 2022
Require Node.js 12 and move to ESM (#56)
1 parent a84befb commit c65a1bb

File tree

8 files changed

+150
-153
lines changed

8 files changed

+150
-153
lines changed
 

‎.github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
node-version:
1313
- 14
1414
- 12
15-
- 10
1615
steps:
1716
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
17+
- uses: actions/setup-node@v2
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

‎index.d.ts

+58-61
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,80 @@
1-
declare namespace prettyMilliseconds {
2-
interface Options {
3-
/**
4-
Number of digits to appear after the seconds decimal point.
1+
export interface Options {
2+
/**
3+
Number of digits to appear after the seconds decimal point.
54
6-
@default 1
7-
*/
8-
readonly secondsDecimalDigits?: number;
5+
@default 1
6+
*/
7+
readonly secondsDecimalDigits?: number;
98

10-
/**
11-
Number of digits to appear after the milliseconds decimal point.
9+
/**
10+
Number of digits to appear after the milliseconds decimal point.
1211
13-
Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime).
12+
Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime).
1413
15-
@default 0
16-
*/
17-
readonly millisecondsDecimalDigits?: number;
14+
@default 0
15+
*/
16+
readonly millisecondsDecimalDigits?: number;
1817

19-
/**
20-
Keep milliseconds on whole seconds: `13s` → `13.0s`.
18+
/**
19+
Keep milliseconds on whole seconds: `13s` → `13.0s`.
2120
22-
Useful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.
21+
Useful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.
2322
24-
@default false
25-
*/
26-
readonly keepDecimalsOnWholeSeconds?: boolean;
23+
@default false
24+
*/
25+
readonly keepDecimalsOnWholeSeconds?: boolean;
2726

28-
/**
29-
Only show the first unit: `1h 10m` → `1h`.
27+
/**
28+
Only show the first unit: `1h 10m` → `1h`.
3029
31-
Also ensures that `millisecondsDecimalDigits` and `secondsDecimalDigits` are both set to `0`.
30+
Also ensures that `millisecondsDecimalDigits` and `secondsDecimalDigits` are both set to `0`.
3231
33-
@default false
34-
*/
35-
readonly compact?: boolean;
32+
@default false
33+
*/
34+
readonly compact?: boolean;
3635

37-
/**
38-
Number of units to show. Setting `compact` to `true` overrides this option.
36+
/**
37+
Number of units to show. Setting `compact` to `true` overrides this option.
3938
40-
@default Infinity
41-
*/
42-
readonly unitCount?: number;
39+
@default Infinity
40+
*/
41+
readonly unitCount?: number;
4342

44-
/**
45-
Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`.
43+
/**
44+
Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`.
4645
47-
@default false
48-
*/
49-
readonly verbose?: boolean;
46+
@default false
47+
*/
48+
readonly verbose?: boolean;
5049

51-
/**
52-
Show milliseconds separately. This means they won't be included in the decimal part of the seconds.
50+
/**
51+
Show milliseconds separately. This means they won't be included in the decimal part of the seconds.
5352
54-
@default false
55-
*/
56-
readonly separateMilliseconds?: boolean;
53+
@default false
54+
*/
55+
readonly separateMilliseconds?: boolean;
5756

58-
/**
59-
Show microseconds and nanoseconds.
57+
/**
58+
Show microseconds and nanoseconds.
6059
61-
@default false
62-
*/
63-
readonly formatSubMilliseconds?: boolean;
60+
@default false
61+
*/
62+
readonly formatSubMilliseconds?: boolean;
6463

65-
/**
66-
Display time using colon notation: `5h 1m 45s` → `5:01:45`. Always shows time in at least minutes: `1s` → `0:01`
64+
/**
65+
Display time using colon notation: `5h 1m 45s` → `5:01:45`. Always shows time in at least minutes: `1s` → `0:01`
6766
68-
Useful when you want to display time without the time units, similar to a digital watch.
67+
Useful when you want to display time without the time units, similar to a digital watch.
6968
70-
Setting `colonNotation` to `true` overrides the following options to `false`:
71-
- `compact`
72-
- `formatSubMilliseconds`
73-
- `separateMilliseconds`
74-
- `verbose`
69+
Setting `colonNotation` to `true` overrides the following options to `false`:
70+
- `compact`
71+
- `formatSubMilliseconds`
72+
- `separateMilliseconds`
73+
- `verbose`
7574
76-
@default false
77-
*/
78-
readonly colonNotation?: boolean;
79-
}
75+
@default false
76+
*/
77+
readonly colonNotation?: boolean;
8078
}
8179

8280
/**
@@ -86,7 +84,7 @@ Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 2
8684
8785
@example
8886
```
89-
import prettyMilliseconds = require('pretty-ms');
87+
import prettyMilliseconds from 'pretty-ms';
9088
9189
prettyMilliseconds(1337000000);
9290
//=> '15d 11h 23m 20s'
@@ -118,9 +116,8 @@ prettyMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))
118116
//=> '35m'
119117
```
120118
*/
121-
declare function prettyMilliseconds(
119+
export default function prettyMilliseconds(
122120
milliseconds: number,
123-
options?: prettyMilliseconds.Options
121+
options?: Options
124122
): string;
125123

126-
export = prettyMilliseconds;

‎index.js

+31-32
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
'use strict';
2-
const parseMilliseconds = require('parse-ms');
1+
import parseMilliseconds from 'parse-ms';
32

43
const pluralize = (word, count) => count === 1 ? word : `${word}s`;
54

6-
const SECOND_ROUNDING_EPSILON = 0.0000001;
5+
const SECOND_ROUNDING_EPSILON = 0.000_000_1;
76

8-
module.exports = (milliseconds, options = {}) => {
7+
export default function prettyMilliseconds(milliseconds, options = {}) {
98
if (!Number.isFinite(milliseconds)) {
109
throw new TypeError('Expected a finite number');
1110
}
@@ -60,52 +59,52 @@ module.exports = (milliseconds, options = {}) => {
6059
add(parsed.minutes, 'minute', 'm');
6160

6261
if (
63-
options.separateMilliseconds ||
64-
options.formatSubMilliseconds ||
65-
(!options.colonNotation && milliseconds < 1000)
62+
options.separateMilliseconds
63+
|| options.formatSubMilliseconds
64+
|| (!options.colonNotation && milliseconds < 1000)
6665
) {
6766
add(parsed.seconds, 'second', 's');
6867
if (options.formatSubMilliseconds) {
6968
add(parsed.milliseconds, 'millisecond', 'ms');
7069
add(parsed.microseconds, 'microsecond', 'µs');
7170
add(parsed.nanoseconds, 'nanosecond', 'ns');
7271
} else {
73-
const millisecondsAndBelow =
74-
parsed.milliseconds +
75-
(parsed.microseconds / 1000) +
76-
(parsed.nanoseconds / 1e6);
72+
const millisecondsAndBelow
73+
= parsed.milliseconds
74+
+ (parsed.microseconds / 1000)
75+
+ (parsed.nanoseconds / 1e6);
7776

78-
const millisecondsDecimalDigits =
79-
typeof options.millisecondsDecimalDigits === 'number' ?
80-
options.millisecondsDecimalDigits :
81-
0;
77+
const millisecondsDecimalDigits
78+
= typeof options.millisecondsDecimalDigits === 'number'
79+
? options.millisecondsDecimalDigits
80+
: 0;
8281

83-
const roundedMiliseconds = millisecondsAndBelow >= 1 ?
84-
Math.round(millisecondsAndBelow) :
85-
Math.ceil(millisecondsAndBelow);
82+
const roundedMiliseconds = millisecondsAndBelow >= 1
83+
? Math.round(millisecondsAndBelow)
84+
: Math.ceil(millisecondsAndBelow);
8685

87-
const millisecondsString = millisecondsDecimalDigits ?
88-
millisecondsAndBelow.toFixed(millisecondsDecimalDigits) :
89-
roundedMiliseconds;
86+
const millisecondsString = millisecondsDecimalDigits
87+
? millisecondsAndBelow.toFixed(millisecondsDecimalDigits)
88+
: roundedMiliseconds;
9089

9190
add(
92-
Number.parseFloat(millisecondsString, 10),
91+
Number.parseFloat(millisecondsString),
9392
'millisecond',
9493
'ms',
95-
millisecondsString
94+
millisecondsString,
9695
);
9796
}
9897
} else {
9998
const seconds = (milliseconds / 1000) % 60;
100-
const secondsDecimalDigits =
101-
typeof options.secondsDecimalDigits === 'number' ?
102-
options.secondsDecimalDigits :
103-
1;
99+
const secondsDecimalDigits
100+
= typeof options.secondsDecimalDigits === 'number'
101+
? options.secondsDecimalDigits
102+
: 1;
104103
const secondsFixed = floorDecimals(seconds, secondsDecimalDigits);
105-
const secondsString = options.keepDecimalsOnWholeSeconds ?
106-
secondsFixed :
107-
secondsFixed.replace(/\.0+$/, '');
108-
add(Number.parseFloat(secondsString, 10), 'second', 's', secondsString);
104+
const secondsString = options.keepDecimalsOnWholeSeconds
105+
? secondsFixed
106+
: secondsFixed.replace(/\.0+$/, '');
107+
add(Number.parseFloat(secondsString), 'second', 's', secondsString);
109108
}
110109

111110
if (result.length === 0) {
@@ -122,4 +121,4 @@ module.exports = (milliseconds, options = {}) => {
122121
}
123122

124123
return options.colonNotation ? result.join('') : result.join(' ');
125-
};
124+
}

‎index.test-d.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import {expectType} from 'tsd';
2-
import prettyMilliseconds = require('.');
2+
import prettyMilliseconds from './index.js';
33

4-
expectType<string>(prettyMilliseconds(1335669000));
5-
expectType<string>(prettyMilliseconds(1335669000, {secondsDecimalDigits: 1}));
4+
expectType<string>(prettyMilliseconds(1_335_669_000));
5+
expectType<string>(prettyMilliseconds(1_335_669_000, {secondsDecimalDigits: 1}));
66
expectType<string>(
7-
prettyMilliseconds(1335669000, {millisecondsDecimalDigits: 2})
7+
prettyMilliseconds(1_335_669_000, {millisecondsDecimalDigits: 2}),
88
);
99
expectType<string>(
10-
prettyMilliseconds(1335669000, {keepDecimalsOnWholeSeconds: true})
10+
prettyMilliseconds(1_335_669_000, {keepDecimalsOnWholeSeconds: true}),
1111
);
1212
expectType<string>(prettyMilliseconds(1337, {compact: true}));
13-
expectType<string>(prettyMilliseconds(1335669000, {unitCount: 2}));
14-
expectType<string>(prettyMilliseconds(1335669000, {verbose: true}));
13+
expectType<string>(prettyMilliseconds(1_335_669_000, {unitCount: 2}));
14+
expectType<string>(prettyMilliseconds(1_335_669_000, {verbose: true}));
1515
expectType<string>(
16-
prettyMilliseconds(1335669000, {separateMilliseconds: true})
16+
prettyMilliseconds(1_335_669_000, {separateMilliseconds: true}),
1717
);
1818
expectType<string>(
19-
prettyMilliseconds(1335669000, {formatSubMilliseconds: true})
19+
prettyMilliseconds(1_335_669_000, {formatSubMilliseconds: true}),
2020
);
2121
expectType<string>(
22-
prettyMilliseconds(1335669000, {colonNotation: true})
22+
prettyMilliseconds(1_335_669_000, {colonNotation: true}),
2323
);

‎license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

‎package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"email": "sindresorhus@gmail.com",
1111
"url": "https://sindresorhus.com"
1212
},
13+
"type": "module",
14+
"exports": "./index.js",
1315
"engines": {
14-
"node": ">=10"
16+
"node": ">=12"
1517
},
1618
"scripts": {
1719
"test": "xo && ava && tsd"
@@ -39,11 +41,11 @@
3941
"hrtime"
4042
],
4143
"dependencies": {
42-
"parse-ms": "^2.1.0"
44+
"parse-ms": "^3.0.0"
4345
},
4446
"devDependencies": {
45-
"ava": "^2.4.0",
46-
"tsd": "^0.11.0",
47-
"xo": "^0.30.0"
47+
"ava": "^3.15.0",
48+
"tsd": "^0.19.0",
49+
"xo": "^0.47.0"
4850
}
4951
}

‎readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ npm install pretty-ms
1111
## Usage
1212

1313
```js
14-
const prettyMilliseconds = require('pretty-ms');
14+
import prettyMilliseconds from 'pretty-ms';
1515

1616
prettyMilliseconds(1337000000);
1717
//=> '15d 11h 23m 20s'

‎test.js

+41-41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import prettyMilliseconds from '.';
2+
import prettyMilliseconds from './index.js';
33

44
test('prettify milliseconds', t => {
55
t.is(prettyMilliseconds(0), '0ms');
@@ -18,8 +18,8 @@ test('prettify milliseconds', t => {
1818
t.is(prettyMilliseconds(1000 * 60 * 60 * 999), '41d 15h');
1919
t.is(prettyMilliseconds(1000 * 60 * 60 * 24 * 465), '1y 100d');
2020
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465), '1y 154d 6h');
21-
t.is(prettyMilliseconds(119999), '1m 59.9s');
22-
t.is(prettyMilliseconds(120000), '2m');
21+
t.is(prettyMilliseconds(119_999), '1m 59.9s');
22+
t.is(prettyMilliseconds(120_000), '2m');
2323
});
2424

2525
test('have a compact option', t => {
@@ -40,14 +40,14 @@ test('have a unitCount option', t => {
4040
});
4141

4242
test('have a secondsDecimalDigits option', t => {
43-
t.is(prettyMilliseconds(10000), '10s');
44-
t.is(prettyMilliseconds(33333), '33.3s');
43+
t.is(prettyMilliseconds(10_000), '10s');
44+
t.is(prettyMilliseconds(33_333), '33.3s');
4545
t.is(prettyMilliseconds(999, {secondsDecimalDigits: 0}), '999ms');
4646
t.is(prettyMilliseconds(1000, {secondsDecimalDigits: 0}), '1s');
4747
t.is(prettyMilliseconds(1999, {secondsDecimalDigits: 0}), '1s');
4848
t.is(prettyMilliseconds(2000, {secondsDecimalDigits: 0}), '2s');
49-
t.is(prettyMilliseconds(33333, {secondsDecimalDigits: 0}), '33s');
50-
t.is(prettyMilliseconds(33333, {secondsDecimalDigits: 4}), '33.3330s');
49+
t.is(prettyMilliseconds(33_333, {secondsDecimalDigits: 0}), '33s');
50+
t.is(prettyMilliseconds(33_333, {secondsDecimalDigits: 4}), '33.3330s');
5151
});
5252

5353
test('have a millisecondsDecimalDigits option', t => {
@@ -58,7 +58,7 @@ test('have a millisecondsDecimalDigits option', t => {
5858

5959
test('have a keepDecimalsOnWholeSeconds option', t => {
6060
t.is(prettyMilliseconds(1000 * 33, {secondsDecimalDigits: 2, keepDecimalsOnWholeSeconds: true}), '33.00s');
61-
t.is(prettyMilliseconds(1000 * 33.00004, {secondsDecimalDigits: 2, keepDecimalsOnWholeSeconds: true}), '33.00s');
61+
t.is(prettyMilliseconds(1000 * 33.000_04, {secondsDecimalDigits: 2, keepDecimalsOnWholeSeconds: true}), '33.00s');
6262
});
6363

6464
test('have a verbose option', t => {
@@ -89,20 +89,20 @@ test('have a separateMilliseconds option', t => {
8989

9090
test('have a formatSubMilliseconds option', t => {
9191
t.is(prettyMilliseconds(0.4, {formatSubMilliseconds: true}), '400µs');
92-
t.is(prettyMilliseconds(0.123571, {formatSubMilliseconds: true}), '123µs 571ns');
93-
t.is(prettyMilliseconds(0.123456789, {formatSubMilliseconds: true}), '123µs 456ns');
92+
t.is(prettyMilliseconds(0.123_571, {formatSubMilliseconds: true}), '123µs 571ns');
93+
t.is(prettyMilliseconds(0.123_456_789, {formatSubMilliseconds: true}), '123µs 456ns');
9494
t.is(
95-
prettyMilliseconds((60 * 60 * 1000) + (23 * 1000) + 433 + 0.123456, {
96-
formatSubMilliseconds: true
95+
prettyMilliseconds((60 * 60 * 1000) + (23 * 1000) + 433 + 0.123_456, {
96+
formatSubMilliseconds: true,
9797
}),
98-
'1h 23s 433ms 123µs 456ns'
98+
'1h 23s 433ms 123µs 456ns',
9999
);
100100
});
101101

102102
test('work with verbose and compact options', t => {
103103
const fn = milliseconds => prettyMilliseconds(milliseconds, {
104104
verbose: true,
105-
compact: true
105+
compact: true,
106106
});
107107

108108
t.is(fn(1000), '1 second');
@@ -132,20 +132,20 @@ test('work with verbose and unitCount options', t => {
132132
test('work with verbose and secondsDecimalDigits options', t => {
133133
const fn = milliseconds => prettyMilliseconds(milliseconds, {
134134
verbose: true,
135-
secondsDecimalDigits: 4
135+
secondsDecimalDigits: 4,
136136
});
137137

138138
t.is(fn(1000), '1 second');
139139
t.is(fn(1000 + 400), '1.4000 seconds');
140140
t.is(fn((1000 * 2) + 400), '2.4000 seconds');
141141
t.is(fn((1000 * 5) + 254), '5.2540 seconds');
142-
t.is(fn(33333), '33.3330 seconds');
142+
t.is(fn(33_333), '33.3330 seconds');
143143
});
144144

145145
test('work with verbose and millisecondsDecimalDigits options', t => {
146146
const fn = milliseconds => prettyMilliseconds(milliseconds, {
147147
verbose: true,
148-
millisecondsDecimalDigits: 4
148+
millisecondsDecimalDigits: 4,
149149
});
150150

151151
t.is(fn(1), '1.0000 millisecond');
@@ -158,25 +158,25 @@ test('work with verbose and millisecondsDecimalDigits options', t => {
158158
test('work with verbose and formatSubMilliseconds options', t => {
159159
t.is(
160160
prettyMilliseconds(0.4, {formatSubMilliseconds: true, verbose: true}),
161-
'400 microseconds'
161+
'400 microseconds',
162162
);
163163
t.is(
164-
prettyMilliseconds(0.123571, {
164+
prettyMilliseconds(0.123_571, {
165165
formatSubMilliseconds: true,
166-
verbose: true
166+
verbose: true,
167167
}),
168-
'123 microseconds 571 nanoseconds'
168+
'123 microseconds 571 nanoseconds',
169169
);
170170
t.is(
171-
prettyMilliseconds(0.123456789, {
171+
prettyMilliseconds(0.123_456_789, {
172172
formatSubMilliseconds: true,
173-
verbose: true
173+
verbose: true,
174174
}),
175-
'123 microseconds 456 nanoseconds'
175+
'123 microseconds 456 nanoseconds',
176176
);
177177
t.is(
178178
prettyMilliseconds(0.001, {formatSubMilliseconds: true, verbose: true}),
179-
'1 microsecond'
179+
'1 microsecond',
180180
);
181181
});
182182

@@ -188,18 +188,18 @@ test('compact option overrides unitCount option', t => {
188188

189189
test('work with separateMilliseconds and formatSubMilliseconds options', t => {
190190
t.is(
191-
prettyMilliseconds(1010.340067, {
191+
prettyMilliseconds(1010.340_067, {
192192
separateMilliseconds: true,
193-
formatSubMilliseconds: true
193+
formatSubMilliseconds: true,
194194
}),
195-
'1s 10ms 340µs 67ns'
195+
'1s 10ms 340µs 67ns',
196196
);
197197
t.is(
198-
prettyMilliseconds((60 * 1000) + 34 + 0.000005, {
198+
prettyMilliseconds((60 * 1000) + 34 + 0.000_005, {
199199
separateMilliseconds: true,
200-
formatSubMilliseconds: true
200+
formatSubMilliseconds: true,
201201
}),
202-
'1m 34ms 5ns'
202+
'1m 34ms 5ns',
203203
);
204204
});
205205

@@ -213,15 +213,15 @@ test('throw on invalid', t => {
213213
});
214214

215215
t.throws(() => {
216-
prettyMilliseconds(Infinity);
216+
prettyMilliseconds(Number.POSITIVE_INFINITY);
217217
});
218218
});
219219

220220
test('properly rounds milliseconds with secondsDecimalDigits', t => {
221221
const fn = milliseconds =>
222222
prettyMilliseconds(milliseconds, {
223223
verbose: true,
224-
secondsDecimalDigits: 0
224+
secondsDecimalDigits: 0,
225225
});
226226
t.is(fn(3 * 60 * 1000), '3 minutes');
227227
t.is(fn((3 * 60 * 1000) - 1), '2 minutes 59 seconds');
@@ -241,7 +241,7 @@ test('`colonNotation` option', t => {
241241
t.is(prettyMilliseconds(1543, {colonNotation: true}), '0:01.5');
242242
t.is(prettyMilliseconds(1000 * 60, {colonNotation: true}), '1:00');
243243
t.is(prettyMilliseconds(1000 * 90, {colonNotation: true}), '1:30');
244-
t.is(prettyMilliseconds(95543, {colonNotation: true}), '1:35.5');
244+
t.is(prettyMilliseconds(95_543, {colonNotation: true}), '1:35.5');
245245
t.is(prettyMilliseconds((1000 * 60 * 10) + 543, {colonNotation: true}), '10:00.5');
246246
t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '59:59.5');
247247
t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '15:59:59.5');
@@ -263,10 +263,10 @@ test('`colonNotation` option', t => {
263263
t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 1}), '0:01.5');
264264
t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 2}), '0:01.54');
265265
t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 3}), '0:01.543');
266-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 0}), '1:35');
267-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 1}), '1:35.5');
268-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 2}), '1:35.54');
269-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 3}), '1:35.543');
266+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 0}), '1:35');
267+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 1}), '1:35.5');
268+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 2}), '1:35.54');
269+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 3}), '1:35.543');
270270
t.is(prettyMilliseconds((1000 * 60 * 10) + 543, {colonNotation: true, secondsDecimalDigits: 3}), '10:00.543');
271271
t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, secondsDecimalDigits: 3}), '15:59:59.543');
272272

@@ -287,9 +287,9 @@ test('`colonNotation` option', t => {
287287
t.is(prettyMilliseconds(1000 * 90, {colonNotation: true, secondsDecimalDigits: 0, unitCount: 1}), '1');
288288
t.is(prettyMilliseconds(1000 * 90, {colonNotation: true, secondsDecimalDigits: 0, unitCount: 2}), '1:30');
289289
t.is(prettyMilliseconds(1000 * 60 * 90, {colonNotation: true, secondsDecimalDigits: 0, unitCount: 3}), '1:30:00');
290-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 1, unitCount: 1}), '1');
291-
t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 1, unitCount: 2}), '1:35.5');
292-
t.is(prettyMilliseconds(95543 + (1000 * 60 * 60), {colonNotation: true, secondsDecimalDigits: 1, unitCount: 3}), '1:01:35.5');
290+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 1, unitCount: 1}), '1');
291+
t.is(prettyMilliseconds(95_543, {colonNotation: true, secondsDecimalDigits: 1, unitCount: 2}), '1:35.5');
292+
t.is(prettyMilliseconds(95_543 + (1000 * 60 * 60), {colonNotation: true, secondsDecimalDigits: 1, unitCount: 3}), '1:01:35.5');
293293

294294
// Make sure incompatible options fall back to `colonNotation`
295295
t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, formatSubMilliseconds: true}), '59:59.5');

0 commit comments

Comments
 (0)
Please sign in to comment.