diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/ms | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) | |
download | wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.xz |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'node_modules/ms')
-rw-r--r-- | node_modules/ms/.npmignore | 5 | ||||
-rw-r--r-- | node_modules/ms/History.md | 66 | ||||
-rw-r--r-- | node_modules/ms/LICENSE | 20 | ||||
-rw-r--r-- | node_modules/ms/README.md | 33 | ||||
-rw-r--r-- | node_modules/ms/index.js | 102 | ||||
-rw-r--r-- | node_modules/ms/package.json | 34 |
6 files changed, 113 insertions, 147 deletions
diff --git a/node_modules/ms/.npmignore b/node_modules/ms/.npmignore deleted file mode 100644 index d1aa0ce42..000000000 --- a/node_modules/ms/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -test -History.md -Makefile -component.json diff --git a/node_modules/ms/History.md b/node_modules/ms/History.md deleted file mode 100644 index 32fdfc176..000000000 --- a/node_modules/ms/History.md +++ /dev/null @@ -1,66 +0,0 @@ - -0.7.1 / 2015-04-20 -================== - - * prevent extraordinary long inputs (@evilpacket) - * Fixed broken readme link - -0.7.0 / 2014-11-24 -================== - - * add time abbreviations, updated tests and readme for the new units - * fix example in the readme. - * add LICENSE file - -0.6.2 / 2013-12-05 -================== - - * Adding repository section to package.json to suppress warning from NPM. - -0.6.1 / 2013-05-10 -================== - - * fix singularization [visionmedia] - -0.6.0 / 2013-03-15 -================== - - * fix minutes - -0.5.1 / 2013-02-24 -================== - - * add component namespace - -0.5.0 / 2012-11-09 -================== - - * add short formatting as default and .long option - * add .license property to component.json - * add version to component.json - -0.4.0 / 2012-10-22 -================== - - * add rounding to fix crazy decimals - -0.3.0 / 2012-09-07 -================== - - * fix `ms(<String>)` [visionmedia] - -0.2.0 / 2012-09-03 -================== - - * add component.json [visionmedia] - * add days support [visionmedia] - * add hours support [visionmedia] - * add minutes support [visionmedia] - * add seconds support [visionmedia] - * add ms string support [visionmedia] - * refactor tests to facilitate ms(number) [visionmedia] - -0.1.0 / 2012-03-07 -================== - - * Initial release diff --git a/node_modules/ms/LICENSE b/node_modules/ms/LICENSE deleted file mode 100644 index 6c07561b6..000000000 --- a/node_modules/ms/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch <rauchg@gmail.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/ms/README.md b/node_modules/ms/README.md index 9b4fd0358..5b475707d 100644 --- a/node_modules/ms/README.md +++ b/node_modules/ms/README.md @@ -1,4 +1,12 @@ -# ms.js: miliseconds conversion utility +# 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/) + +Use this package to easily convert various time formats to milliseconds. + +## Examples ```js ms('2 days') // 172800000 @@ -8,28 +16,37 @@ ms('2.5 hrs') // 9000000 ms('2h') // 7200000 ms('1m') // 60000 ms('5s') // 5000 +ms('1y') // 31557600000 ms('100') // 100 ``` +### Convert from milliseconds + ```js ms(60000) // "1m" ms(2 * 60000) // "2m" ms(ms('10 hours')) // "10h" ``` +### Time format written-out + ```js ms(60000, { long: true }) // "1 minute" ms(2 * 60000, { long: true }) // "2 minutes" ms(ms('10 hours'), { long: true }) // "10 hours" ``` -- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). +## Features + +- Works both in [node](https://nodejs.org) and in the browser. - If a number is supplied to `ms`, a string with a unit is returned. -- If a string that contains the number is supplied, it returns it as -a number (e.g: it returns `100` for `'100'`). -- If you pass a string with a number and a valid unit, the number of -equivalent ms is returned. +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`). +- If you pass a string with a number and a valid unit, the number of equivalent ms is returned. + +## Caught a bug? -## License +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device +2. Link the package to the global module directory: `npm link` +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms! -MIT +As always, you can run the tests using: `npm test` diff --git a/node_modules/ms/index.js b/node_modules/ms/index.js index 4f9277169..824b37eba 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`. @@ -17,17 +17,23 @@ var y = d * 365.25; * * @param {String|Number} val * @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 || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; +module.exports = function (val, options) { + options = options || {} + var type = typeof val + if (type === 'string' && val.length > 0) { + return parse(val) + } else if (type === 'number' && isNaN(val) === false) { + 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)) +} /** * Parse the given `str` and return milliseconds. @@ -38,47 +44,53 @@ module.exports = function(val, options){ */ function parse(str) { - str = '' + str; - if (str.length > 10000) 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); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); + str = String(str) + if (str.length > 10000) { + 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) + if (!match) { + return + } + 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 } } @@ -90,12 +102,20 @@ function parse(str) { * @api private */ -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd' + } + if (ms >= h) { + return Math.round(ms / h) + 'h' + } + if (ms >= m) { + return Math.round(ms / m) + 'm' + } + if (ms >= s) { + return Math.round(ms / s) + 's' + } + return ms + 'ms' } /** @@ -106,12 +126,12 @@ function short(ms) { * @api private */ -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms' } /** @@ -119,7 +139,11 @@ function long(ms) { */ function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; + if (ms < n) { + return + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name + } + return Math.ceil(ms / n) + ' ' + name + 's' } diff --git a/node_modules/ms/package.json b/node_modules/ms/package.json index a4e5bb603..58060aa58 100644 --- a/node_modules/ms/package.json +++ b/node_modules/ms/package.json @@ -1,20 +1,36 @@ { "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" - }, + "version": "0.7.2", + "description": "Tiny milisecond conversion utility", + "repository": "zeit/ms", "main": "./index", + "files": [ + "index.js" + ], + "scripts": { + "test": "xo && mocha test/index.js", + "test-browser": "serve ./test" + }, + "license": "MIT", "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" + "expect.js": "^0.3.1", + "mocha": "^3.0.2", + "serve": "^1.4.0", + "xo": "^0.17.0" }, "component": { "scripts": { "ms/index.js": "index.js" } + }, + "xo": { + "space": true, + "semicolon": false, + "envs": [ + "mocha" + ], + "rules": { + "complexity": 0 + } } } |