Comparing version
14
index.js
@@ -41,3 +41,3 @@ /** | ||
function parse(str) { | ||
var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|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; | ||
@@ -49,2 +49,4 @@ var n = parseFloat(match[1]); | ||
case 'year': | ||
case 'yrs': | ||
case 'yr': | ||
case 'y': | ||
@@ -58,2 +60,4 @@ return n * y; | ||
case 'hour': | ||
case 'hrs': | ||
case 'hr': | ||
case 'h': | ||
@@ -63,2 +67,4 @@ return n * h; | ||
case 'minute': | ||
case 'mins': | ||
case 'min': | ||
case 'm': | ||
@@ -68,4 +74,10 @@ return n * m; | ||
case 'second': | ||
case 'secs': | ||
case 'sec': | ||
case 's': | ||
return n * s; | ||
case 'milliseconds': | ||
case 'millisecond': | ||
case 'msecs': | ||
case 'msec': | ||
case 'ms': | ||
@@ -72,0 +84,0 @@ return n; |
{ | ||
"name": "ms", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Tiny ms conversion utility", | ||
@@ -5,0 +5,0 @@ "repository": { |
# ms.js: miliseconds conversion utility | ||
```js | ||
ms('2 days') // 172800000 | ||
ms('1d') // 86400000 | ||
ms('10h') // 36000000 | ||
ms('2.5 hrs') // 9000000 | ||
ms('2h') // 7200000 | ||
@@ -21,6 +23,6 @@ ms('1m') // 60000 | ||
ms(2 * 60000, { long: true }) // "2 minutes" | ||
ms(ms('10 hours', { long: true })) // "10 hours" | ||
ms(ms('10 hours'), { long: true }) // "10 hours" | ||
``` | ||
- Node/Browser compatible. Published as `ms` in NPM. | ||
- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](nodejs.org/download). | ||
- If a number is supplied to `ms`, a string with a unit is returned. | ||
@@ -34,2 +36,2 @@ - If a string that contains the number is supplied, it returns it as | ||
MIT | ||
MIT |
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
4716
45.02%5
25%0
-100%112
12%36
9.09%