diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:10:37 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:11:17 +0200 |
commit | 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch) | |
tree | 70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/ms | |
parent | aca1143cb9eed16cf37f04e475e4257418dd18ac (diff) | |
download | wallet-core-7a3df06eb573d36142bd1a8e03c5ce8752d300b3.tar.xz |
fix build issues and add typedoc
Diffstat (limited to 'node_modules/ms')
-rw-r--r-- | node_modules/ms/index.js | 79 | ||||
-rw-r--r-- | node_modules/ms/license.md (renamed from node_modules/ms/LICENSE.md) | 0 | ||||
-rw-r--r-- | node_modules/ms/package.json | 45 | ||||
-rw-r--r-- | node_modules/ms/readme.md (renamed from node_modules/ms/README.md) | 3 |
4 files changed, 65 insertions, 62 deletions
diff --git a/node_modules/ms/index.js b/node_modules/ms/index.js index 824b37eba..6a522b16b 100644 --- a/node_modules/ms/index.js +++ b/node_modules/ms/index.js @@ -2,11 +2,11 @@ * Helpers. */ -var s = 1000 -var m = s * 60 -var h = m * 60 -var d = h * 24 -var y = d * 365.25 +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; /** * Parse or format the given `val`. @@ -16,24 +16,25 @@ var y = d * 365.25 * - `long` verbose formatting [false] * * @param {String|Number} val - * @param {Object} options + * @param {Object} [options] * @throws {Error} throw an error if val is not a non-empty string or a number * @return {String|Number} * @api public */ -module.exports = function (val, options) { - options = options || {} - var type = typeof val +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; if (type === 'string' && val.length > 0) { - return parse(val) + return parse(val); } else if (type === 'number' && isNaN(val) === false) { - return options.long ? - fmtLong(val) : - fmtShort(val) + return options.long ? fmtLong(val) : fmtShort(val); } - throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) -} + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; /** * Parse the given `str` and return milliseconds. @@ -44,53 +45,55 @@ module.exports = function (val, options) { */ function parse(str) { - str = String(str) - if (str.length > 10000) { - return + str = String(str); + if (str.length > 100) { + return; } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + str + ); if (!match) { - return + return; } - var n = parseFloat(match[1]) - var type = (match[2] || 'ms').toLowerCase() + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); switch (type) { case 'years': case 'year': case 'yrs': case 'yr': case 'y': - return n * y + return n * y; case 'days': case 'day': case 'd': - return n * d + return n * d; case 'hours': case 'hour': case 'hrs': case 'hr': case 'h': - return n * h + return n * h; case 'minutes': case 'minute': case 'mins': case 'min': case 'm': - return n * m + return n * m; case 'seconds': case 'second': case 'secs': case 'sec': case 's': - return n * s + return n * s; case 'milliseconds': case 'millisecond': case 'msecs': case 'msec': case 'ms': - return n + return n; default: - return undefined + return undefined; } } @@ -104,18 +107,18 @@ function parse(str) { function fmtShort(ms) { if (ms >= d) { - return Math.round(ms / d) + 'd' + return Math.round(ms / d) + 'd'; } if (ms >= h) { - return Math.round(ms / h) + 'h' + return Math.round(ms / h) + 'h'; } if (ms >= m) { - return Math.round(ms / m) + 'm' + return Math.round(ms / m) + 'm'; } if (ms >= s) { - return Math.round(ms / s) + 's' + return Math.round(ms / s) + 's'; } - return ms + 'ms' + return ms + 'ms'; } /** @@ -131,7 +134,7 @@ function fmtLong(ms) { plural(ms, h, 'hour') || plural(ms, m, 'minute') || plural(ms, s, 'second') || - ms + ' ms' + ms + ' ms'; } /** @@ -140,10 +143,10 @@ function fmtLong(ms) { function plural(ms, n, name) { if (ms < n) { - return + return; } if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name + return Math.floor(ms / n) + ' ' + name; } - return Math.ceil(ms / n) + ' ' + name + 's' + return Math.ceil(ms / n) + ' ' + name + 's'; } diff --git a/node_modules/ms/LICENSE.md b/node_modules/ms/license.md index 69b61253a..69b61253a 100644 --- a/node_modules/ms/LICENSE.md +++ b/node_modules/ms/license.md diff --git a/node_modules/ms/package.json b/node_modules/ms/package.json index 58060aa58..6a31c81fa 100644 --- a/node_modules/ms/package.json +++ b/node_modules/ms/package.json @@ -1,6 +1,6 @@ { "name": "ms", - "version": "0.7.2", + "version": "2.0.0", "description": "Tiny milisecond conversion utility", "repository": "zeit/ms", "main": "./index", @@ -8,29 +8,30 @@ "index.js" ], "scripts": { - "test": "xo && mocha test/index.js", - "test-browser": "serve ./test" + "precommit": "lint-staged", + "lint": "eslint lib/* bin/*", + "test": "mocha tests.js" }, - "license": "MIT", - "devDependencies": { - "expect.js": "^0.3.1", - "mocha": "^3.0.2", - "serve": "^1.4.0", - "xo": "^0.17.0" - }, - "component": { - "scripts": { - "ms/index.js": "index.js" + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "node": true, + "es6": true } }, - "xo": { - "space": true, - "semicolon": false, - "envs": [ - "mocha" - ], - "rules": { - "complexity": 0 - } + "lint-staged": { + "*.js": [ + "npm run lint", + "prettier --single-quote --write", + "git add" + ] + }, + "license": "MIT", + "devDependencies": { + "eslint": "3.19.0", + "expect.js": "0.3.1", + "husky": "0.13.3", + "lint-staged": "3.4.1", + "mocha": "3.4.1" } } diff --git a/node_modules/ms/README.md b/node_modules/ms/readme.md index 5b475707d..84a9974cc 100644 --- a/node_modules/ms/README.md +++ b/node_modules/ms/readme.md @@ -1,8 +1,7 @@ # ms [![Build Status](https://travis-ci.org/zeit/ms.svg?branch=master)](https://travis-ci.org/zeit/ms) -[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) -[![Slack Channel](https://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/) +[![Slack Channel](http://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/) Use this package to easily convert various time formats to milliseconds. |