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.js47
-rw-r--r--node_modules/pretty-ms/license21
-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.json48
-rw-r--r--node_modules/pretty-ms/readme.md89
8 files changed, 324 insertions, 0 deletions
diff --git a/node_modules/pretty-ms/index.js b/node_modules/pretty-ms/index.js
new file mode 100644
index 000000000..74aadf440
--- /dev/null
+++ b/node_modules/pretty-ms/index.js
@@ -0,0 +1,47 @@
+'use strict';
+var parseMs = require('parse-ms');
+var plur = require('plur');
+var isFinitePonyfill = require('is-finite');
+
+module.exports = function (ms, opts) {
+ if (!isFinitePonyfill(ms)) {
+ throw new TypeError('Expected a finite number');
+ }
+
+ opts = opts || {};
+
+ if (ms < 1000) {
+ var 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 = [];
+
+ var add = function (val, long, short, valStr) {
+ if (val === 0) {
+ return;
+ }
+
+ var postfix = opts.verbose ? ' ' + plur(long, val) : short;
+
+ ret.push((valStr || val) + postfix);
+ };
+
+ var parsed = parseMs(ms);
+
+ add(parsed.days, 'day', 'd');
+ add(parsed.hours, 'hour', 'h');
+ add(parsed.minutes, 'minute', 'm');
+
+ if (opts.compact) {
+ add(parsed.seconds, 'second', 's');
+ return '~' + ret[0];
+ }
+
+ var sec = ms / 1000 % 60;
+ var secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
+ var secStr = sec.toFixed(secDecimalDigits).replace(/\.0$/, '');
+ add(sec, 'second', 's', secStr);
+
+ return ret.join(' ');
+};
diff --git a/node_modules/pretty-ms/license b/node_modules/pretty-ms/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/pretty-ms/license
@@ -0,0 +1,21 @@
+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/index.js b/node_modules/pretty-ms/node_modules/plur/index.js
new file mode 100644
index 000000000..0a16a559c
--- /dev/null
+++ b/node_modules/pretty-ms/node_modules/plur/index.js
@@ -0,0 +1,9 @@
+'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
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/pretty-ms/node_modules/plur/license
@@ -0,0 +1,21 @@
+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
new file mode 100644
index 000000000..85fbfd71d
--- /dev/null
+++ b/node_modules/pretty-ms/node_modules/plur/package.json
@@ -0,0 +1,37 @@
+{
+ "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
new file mode 100644
index 000000000..ebc7d43f0
--- /dev/null
+++ b/node_modules/pretty-ms/node_modules/plur/readme.md
@@ -0,0 +1,52 @@
+# 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
new file mode 100644
index 000000000..c7b0c0536
--- /dev/null
+++ b/node_modules/pretty-ms/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "pretty-ms",
+ "version": "2.1.0",
+ "description": "Convert milliseconds to a human readable string: 1337000000 → 15d 11h 23m 20s",
+ "license": "MIT",
+ "repository": "sindresorhus/pretty-ms",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "pretty",
+ "prettify",
+ "human",
+ "humanize",
+ "humanized",
+ "readable",
+ "time",
+ "ms",
+ "milliseconds",
+ "duration",
+ "period",
+ "range",
+ "text",
+ "string",
+ "str",
+ "number",
+ "hrtime"
+ ],
+ "dependencies": {
+ "is-finite": "^1.0.1",
+ "parse-ms": "^1.0.0",
+ "plur": "^1.0.0"
+ },
+ "devDependencies": {
+ "mocha": "*"
+ }
+}
diff --git a/node_modules/pretty-ms/readme.md b/node_modules/pretty-ms/readme.md
new file mode 100644
index 000000000..2a1bf780f
--- /dev/null
+++ b/node_modules/pretty-ms/readme.md
@@ -0,0 +1,89 @@
+# pretty-ms [![Build Status](https://travis-ci.org/sindresorhus/pretty-ms.svg?branch=master)](https://travis-ci.org/sindresorhus/pretty-ms)
+
+> Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
+
+
+## Usage
+
+```
+$ npm install --save pretty-ms
+```
+
+```js
+var prettyMs = require('pretty-ms');
+
+prettyMs(1337000000);
+//=> '15d 11h 23m 20s'
+
+prettyMs(1337);
+//=> '1.3s'
+
+prettyMs(133);
+//=> '133ms'
+
+// compact option
+prettyMs(1337, {compact: true});
+//=> '~1s'
+
+// verbose option
+prettyMs(1335669000, {verbose: true});
+//=> '15 days 11 hours 1 minute 9 seconds'
+
+// can be useful for time durations
+prettyMs(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))
+//=> '35m'
+```
+
+
+## API
+
+### prettyMs(milliseconds, [options])
+
+#### milliseconds
+
+*Required*
+Type: `number`
+
+Milliseconds to humanize.
+
+#### options
+
+##### secDecimalDigits
+
+Type: `number`
+Default: `1`
+
+Number of digits to appear after the seconds decimal point.
+
+##### msDecimalDigits
+
+Type: `number`
+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).
+
+##### compact
+
+Type: `boolean`
+Default: `false`
+
+Only show the first unit: `1h 10m` → `~1h`.
+
+##### verbose
+
+Type: `boolean`
+Default: `false`
+
+Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`
+
+
+## Related
+
+- [pretty-ms-cli](https://github.com/sindresorhus/pretty-ms-cli) - CLI for this module
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)