aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pretty-ms
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/pretty-ms')
-rw-r--r--node_modules/pretty-ms/index.js29
-rw-r--r--node_modules/pretty-ms/license20
-rw-r--r--node_modules/pretty-ms/node_modules/plur/index.js9
-rw-r--r--node_modules/pretty-ms/node_modules/plur/license21
-rw-r--r--node_modules/pretty-ms/node_modules/plur/package.json37
-rw-r--r--node_modules/pretty-ms/node_modules/plur/readme.md52
-rw-r--r--node_modules/pretty-ms/package.json14
-rw-r--r--node_modules/pretty-ms/readme.md30
8 files changed, 46 insertions, 166 deletions
diff --git a/node_modules/pretty-ms/index.js b/node_modules/pretty-ms/index.js
index 74aadf440..c406e16f4 100644
--- a/node_modules/pretty-ms/index.js
+++ b/node_modules/pretty-ms/index.js
@@ -1,35 +1,35 @@
'use strict';
-var parseMs = require('parse-ms');
-var plur = require('plur');
-var isFinitePonyfill = require('is-finite');
+const parseMs = require('parse-ms');
+const plur = require('plur');
-module.exports = function (ms, opts) {
- if (!isFinitePonyfill(ms)) {
+module.exports = (ms, opts) => {
+ if (!Number.isFinite(ms)) {
throw new TypeError('Expected a finite number');
}
opts = opts || {};
if (ms < 1000) {
- var msDecimalDigits = typeof opts.msDecimalDigits === 'number' ? opts.msDecimalDigits : 0;
+ const msDecimalDigits = typeof opts.msDecimalDigits === 'number' ? opts.msDecimalDigits : 0;
return (msDecimalDigits ? ms.toFixed(msDecimalDigits) : Math.ceil(ms)) + (opts.verbose ? ' ' + plur('millisecond', Math.ceil(ms)) : 'ms');
}
- var ret = [];
+ const ret = [];
- var add = function (val, long, short, valStr) {
+ const add = (val, long, short, valStr) => {
if (val === 0) {
return;
}
- var postfix = opts.verbose ? ' ' + plur(long, val) : short;
+ const postfix = opts.verbose ? ' ' + plur(long, val) : short;
ret.push((valStr || val) + postfix);
};
- var parsed = parseMs(ms);
+ const parsed = parseMs(ms);
- add(parsed.days, 'day', 'd');
+ add(Math.trunc(parsed.days / 365), 'year', 'y');
+ add(parsed.days % 365, 'day', 'd');
add(parsed.hours, 'hour', 'h');
add(parsed.minutes, 'minute', 'm');
@@ -38,9 +38,10 @@ module.exports = function (ms, opts) {
return '~' + ret[0];
}
- var sec = ms / 1000 % 60;
- var secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
- var secStr = sec.toFixed(secDecimalDigits).replace(/\.0$/, '');
+ const sec = ms / 1000 % 60;
+ const secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
+ const secFixed = sec.toFixed(secDecimalDigits);
+ const secStr = opts.keepDecimalsOnWholeSeconds ? secFixed : secFixed.replace(/\.0+$/, '');
add(sec, 'second', 's', secStr);
return ret.join(' ');
diff --git a/node_modules/pretty-ms/license b/node_modules/pretty-ms/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/pretty-ms/license
+++ b/node_modules/pretty-ms/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-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:
+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:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/pretty-ms/node_modules/plur/index.js b/node_modules/pretty-ms/node_modules/plur/index.js
deleted file mode 100644
index 0a16a559c..000000000
--- a/node_modules/pretty-ms/node_modules/plur/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-module.exports = function (str, plural, count) {
- if (typeof plural === 'number') {
- count = plural;
- plural = str + 's';
- }
-
- return count === 1 ? str : plural;
-};
diff --git a/node_modules/pretty-ms/node_modules/plur/license b/node_modules/pretty-ms/node_modules/plur/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/pretty-ms/node_modules/plur/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-
-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:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/node_modules/pretty-ms/node_modules/plur/package.json b/node_modules/pretty-ms/node_modules/plur/package.json
deleted file mode 100644
index 85fbfd71d..000000000
--- a/node_modules/pretty-ms/node_modules/plur/package.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "name": "plur",
- "version": "1.0.0",
- "description": "Naively pluralize a word",
- "license": "MIT",
- "repository": "sindresorhus/plur",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "scripts": {
- "test": "node test.js"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "plur",
- "plural",
- "plurals",
- "pluralize",
- "singular",
- "count",
- "word",
- "string",
- "str",
- "naive",
- "simple"
- ],
- "devDependencies": {
- "ava": "0.0.4"
- }
-}
diff --git a/node_modules/pretty-ms/node_modules/plur/readme.md b/node_modules/pretty-ms/node_modules/plur/readme.md
deleted file mode 100644
index ebc7d43f0..000000000
--- a/node_modules/pretty-ms/node_modules/plur/readme.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# plur [![Build Status](https://travis-ci.org/sindresorhus/plur.svg?branch=master)](https://travis-ci.org/sindresorhus/plur)
-
-> Naively pluralize a word
-
-
-## Install
-
-```
-$ npm install --save plur
-```
-
-
-## Usage
-
-```js
-var plur = require('plur');
-
-plur('unicorn', 4);
-//=> 'unicorns'
-
-plur('hero', 'heroes', 4);
-//=> 'heroes'
-```
-
-
-## API
-
-### plur(word, [plural], count)
-
-#### word
-
-Type: `string`
-
-Word to pluralize.
-
-#### plural
-
-Type: `string`
-Default: `word` + `s`
-
-Pluralized word.
-
-#### count
-
-Type: `number`
-
-Count to determine whether to use singular or plural.
-
-
-## License
-
-MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/node_modules/pretty-ms/package.json b/node_modules/pretty-ms/package.json
index c7b0c0536..f6a934a4c 100644
--- a/node_modules/pretty-ms/package.json
+++ b/node_modules/pretty-ms/package.json
@@ -1,7 +1,7 @@
{
"name": "pretty-ms",
- "version": "2.1.0",
- "description": "Convert milliseconds to a human readable string: 1337000000 → 15d 11h 23m 20s",
+ "version": "3.1.0",
+ "description": "Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`",
"license": "MIT",
"repository": "sindresorhus/pretty-ms",
"author": {
@@ -10,10 +10,10 @@
"url": "sindresorhus.com"
},
"engines": {
- "node": ">=0.10.0"
+ "node": ">=4"
},
"scripts": {
- "test": "mocha"
+ "test": "xo && ava"
},
"files": [
"index.js"
@@ -38,11 +38,11 @@
"hrtime"
],
"dependencies": {
- "is-finite": "^1.0.1",
"parse-ms": "^1.0.0",
- "plur": "^1.0.0"
+ "plur": "^2.1.2"
},
"devDependencies": {
- "mocha": "*"
+ "ava": "*",
+ "xo": "*"
}
}
diff --git a/node_modules/pretty-ms/readme.md b/node_modules/pretty-ms/readme.md
index 2a1bf780f..01bab490b 100644
--- a/node_modules/pretty-ms/readme.md
+++ b/node_modules/pretty-ms/readme.md
@@ -6,11 +6,11 @@
## Usage
```
-$ npm install --save pretty-ms
+$ npm install pretty-ms
```
```js
-var prettyMs = require('pretty-ms');
+const prettyMs = require('pretty-ms');
prettyMs(1337000000);
//=> '15d 11h 23m 20s'
@@ -37,43 +37,53 @@ prettyMs(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))
## API
-### prettyMs(milliseconds, [options])
+### prettyMs(input, [options])
-#### milliseconds
+#### input
-*Required*
Type: `number`
Milliseconds to humanize.
#### options
+Type: `Object`
+
##### secDecimalDigits
-Type: `number`
+Type: `number`<br>
Default: `1`
Number of digits to appear after the seconds decimal point.
##### msDecimalDigits
-Type: `number`
+Type: `number`<br>
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).
+##### keepDecimalsOnWholeSeconds
+
+Type: `boolean`<br>
+Default: `false`
+
+Keep milliseconds on whole seconds: `13s` → `13.0s`.
+
+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.
+
##### compact
-Type: `boolean`
+Type: `boolean`<br>
Default: `false`
Only show the first unit: `1h 10m` → `~1h`.
##### verbose
-Type: `boolean`
+Type: `boolean`<br>
Default: `false`
Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`
@@ -86,4 +96,4 @@ Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`
## License
-MIT © [Sindre Sorhus](http://sindresorhus.com)
+MIT © [Sindre Sorhus](https://sindresorhus.com)