Fix dependabot issues
This commit is contained in:
parent
c89d9bd8b0
commit
531c6ba7c8
705 changed files with 53406 additions and 20466 deletions
42
node_modules/pretty-ms/index.js
generated
vendored
42
node_modules/pretty-ms/index.js
generated
vendored
|
|
@ -3,6 +3,8 @@ const parseMilliseconds = require('parse-ms');
|
|||
|
||||
const pluralize = (word, count) => count === 1 ? word : `${word}s`;
|
||||
|
||||
const SECOND_ROUNDING_EPSILON = 0.0000001;
|
||||
|
||||
module.exports = (milliseconds, options = {}) => {
|
||||
if (!Number.isFinite(milliseconds)) {
|
||||
throw new TypeError('Expected a finite number');
|
||||
|
|
@ -22,6 +24,12 @@ module.exports = (milliseconds, options = {}) => {
|
|||
|
||||
const result = [];
|
||||
|
||||
const floorDecimals = (value, decimalDigits) => {
|
||||
const flooredInterimValue = Math.floor((value * (10 ** decimalDigits)) + SECOND_ROUNDING_EPSILON);
|
||||
const flooredValue = Math.round(flooredInterimValue) / (10 ** decimalDigits);
|
||||
return flooredValue.toFixed(decimalDigits);
|
||||
};
|
||||
|
||||
const add = (value, long, short, valueString) => {
|
||||
if ((result.length === 0 || !options.colonNotation) && value === 0 && !(options.colonNotation && short === 'm')) {
|
||||
return;
|
||||
|
|
@ -44,32 +52,6 @@ module.exports = (milliseconds, options = {}) => {
|
|||
result.push(prefix + valueString + suffix);
|
||||
};
|
||||
|
||||
const secondsDecimalDigits =
|
||||
typeof options.secondsDecimalDigits === 'number' ?
|
||||
options.secondsDecimalDigits :
|
||||
1;
|
||||
|
||||
if (secondsDecimalDigits < 1) {
|
||||
const difference = 1000 - (milliseconds % 1000);
|
||||
if (difference < 500) {
|
||||
milliseconds += difference;
|
||||
}
|
||||
}
|
||||
|
||||
// Round up milliseconds for values lager than 1 minute - 50ms since these
|
||||
// always need to be round up. This fixes issues when rounding seconds
|
||||
// independently of minutes later on.
|
||||
if (
|
||||
milliseconds >= (1000 * 60) - 50 &&
|
||||
!options.separateMilliseconds &&
|
||||
!options.formatSubMilliseconds
|
||||
) {
|
||||
const difference = 60 - (milliseconds % 60);
|
||||
if (difference <= 50) {
|
||||
milliseconds += difference;
|
||||
}
|
||||
}
|
||||
|
||||
const parsed = parseMilliseconds(milliseconds);
|
||||
|
||||
add(Math.trunc(parsed.days / 365), 'year', 'y');
|
||||
|
|
@ -80,7 +62,7 @@ module.exports = (milliseconds, options = {}) => {
|
|||
if (
|
||||
options.separateMilliseconds ||
|
||||
options.formatSubMilliseconds ||
|
||||
milliseconds < 1000
|
||||
(!options.colonNotation && milliseconds < 1000)
|
||||
) {
|
||||
add(parsed.seconds, 'second', 's');
|
||||
if (options.formatSubMilliseconds) {
|
||||
|
|
@ -107,7 +89,7 @@ module.exports = (milliseconds, options = {}) => {
|
|||
roundedMiliseconds;
|
||||
|
||||
add(
|
||||
parseFloat(millisecondsString, 10),
|
||||
Number.parseFloat(millisecondsString, 10),
|
||||
'millisecond',
|
||||
'ms',
|
||||
millisecondsString
|
||||
|
|
@ -119,11 +101,11 @@ module.exports = (milliseconds, options = {}) => {
|
|||
typeof options.secondsDecimalDigits === 'number' ?
|
||||
options.secondsDecimalDigits :
|
||||
1;
|
||||
const secondsFixed = seconds.toFixed(secondsDecimalDigits);
|
||||
const secondsFixed = floorDecimals(seconds, secondsDecimalDigits);
|
||||
const secondsString = options.keepDecimalsOnWholeSeconds ?
|
||||
secondsFixed :
|
||||
secondsFixed.replace(/\.0+$/, '');
|
||||
add(parseFloat(secondsString, 10), 'second', 's', secondsString);
|
||||
add(Number.parseFloat(secondsString, 10), 'second', 's', secondsString);
|
||||
}
|
||||
|
||||
if (result.length === 0) {
|
||||
|
|
|
|||
6
node_modules/pretty-ms/package.json
generated
vendored
6
node_modules/pretty-ms/package.json
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pretty-ms",
|
||||
"version": "6.0.1",
|
||||
"version": "7.0.1",
|
||||
"description": "Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/pretty-ms",
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
|
|
@ -44,6 +44,6 @@
|
|||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
"xo": "^0.30.0"
|
||||
}
|
||||
}
|
||||
4
node_modules/pretty-ms/readme.md
generated
vendored
4
node_modules/pretty-ms/readme.md
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
# pretty-ms [](https://travis-ci.org/sindresorhus/pretty-ms)
|
||||
# pretty-ms [](https://travis-ci.com/sindresorhus/pretty-ms)
|
||||
|
||||
> Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ Default: `0`
|
|||
|
||||
Number of digits to appear after the milliseconds decimal point.
|
||||
|
||||
Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime).
|
||||
Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime_time).
|
||||
|
||||
##### keepDecimalsOnWholeSeconds
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue