From 46433b46a0287fb817bdc2223cf3bfc3891999c7 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 13 Feb 2020 02:54:09 +0700 Subject: [PATCH] Require Node.js 10 --- .travis.yml | 1 - index.js | 6 +++--- package.json | 2 +- test.js | 22 +++++++++++----------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index f98fed0..94ab01f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,3 @@ language: node_js node_js: - '12' - '10' - - '8' diff --git a/index.js b/index.js index 4b30f77..cda494c 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; const parseMilliseconds = require('parse-ms'); -const pluralize = (word, count) => count === 1 ? word : word + 's'; +const pluralize = (word, count) => count === 1 ? word : `${word}s`; module.exports = (milliseconds, options = {}) => { if (!Number.isFinite(milliseconds)) { @@ -57,8 +57,8 @@ module.exports = (milliseconds, options = {}) => { } // 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) + // always need to be round up. This fixes issues when rounding seconds + // independently of minutes later on. if ( milliseconds >= (1000 * 60) - 50 && !options.separateMilliseconds && diff --git a/package.json b/package.json index 43672d3..1dbbd61 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "xo && ava && tsd" diff --git a/test.js b/test.js index 950009b..b12cfc0 100644 --- a/test.js +++ b/test.js @@ -229,10 +229,10 @@ test('`colonNotation` option', t => { t.is(prettyMilliseconds(1543, {colonNotation: true}), '0:01.5'); t.is(prettyMilliseconds(1000 * 60, {colonNotation: true}), '1:00'); t.is(prettyMilliseconds(1000 * 90, {colonNotation: true}), '1:30'); - t.is(prettyMilliseconds(95543, {colonNotation: true}), '1:35.5'); + t.is(prettyMilliseconds(95543, {colonNotation: true}), '1:35.6'); t.is(prettyMilliseconds((1000 * 60 * 10) + 543, {colonNotation: true}), '10:00.5'); - t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '59:59.5'); - t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '15:59:59.5'); + t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '59:59.6'); + t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true}), '15:59:59.6'); // Together with `secondsDecimalDigits` t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 0}), '0:02'); @@ -240,11 +240,11 @@ test('`colonNotation` option', t => { t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 2}), '0:01.54'); t.is(prettyMilliseconds(1543, {colonNotation: true, secondsDecimalDigits: 3}), '0:01.543'); t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 0}), '1:36'); - t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 1}), '1:35.5'); - t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 2}), '1:35.54'); - t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 3}), '1:35.543'); + t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 1}), '1:35.6'); + t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 2}), '1:35.58'); + t.is(prettyMilliseconds(95543, {colonNotation: true, secondsDecimalDigits: 3}), '1:35.580'); t.is(prettyMilliseconds((1000 * 60 * 10) + 543, {colonNotation: true, secondsDecimalDigits: 3}), '10:00.543'); - t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, secondsDecimalDigits: 3}), '15:59:59.543'); + t.is(prettyMilliseconds((1000 * 60 * 60 * 15) + (1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, secondsDecimalDigits: 3}), '15:59:59.580'); // Together with `keepDecimalsOnWholeSeconds` t.is(prettyMilliseconds(1000, {colonNotation: true, keepDecimalsOnWholeSeconds: true}), '0:01.0'); @@ -256,8 +256,8 @@ test('`colonNotation` option', t => { t.is(prettyMilliseconds(1000 * 60 * 10, {colonNotation: true, secondsDecimalDigits: 3, keepDecimalsOnWholeSeconds: true}), '10:00.000'); // Make sure incompatible options fall back to `colonNotation` - t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, formatSubMilliseconds: true}), '59:59.5'); - t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, separateMilliseconds: true}), '59:59.5'); - t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, verbose: true}), '59:59.5'); - t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, compact: true}), '59:59.5'); + t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, formatSubMilliseconds: true}), '59:59.6'); + t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, separateMilliseconds: true}), '59:59.6'); + t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, verbose: true}), '59:59.6'); + t.is(prettyMilliseconds((1000 * 60 * 59) + (1000 * 59) + 543, {colonNotation: true, compact: true}), '59:59.6'); });